1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2012, 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
24 /* lib591 is used for test cases 591, 592, 593 and 594 */
34 #define TEST_HANG_TIMEOUT 60 * 1000
48 upload = fopen(libtest_arg3, "rb");
50 fprintf(stderr, "fopen() failed with error: %d (%s)\n",
51 errno, strerror(errno));
52 fprintf(stderr, "Error opening file: (%s)\n", libtest_arg3);
53 return TEST_ERR_FOPEN;
56 res_global_init(CURL_GLOBAL_ALL);
65 easy_setopt(easy, CURLOPT_VERBOSE, 1L);
68 easy_setopt(easy, CURLOPT_URL, URL);
70 /* enable uploading */
71 easy_setopt(easy, CURLOPT_UPLOAD, 1L);
73 /* data pointer for the file read function */
74 easy_setopt(easy, CURLOPT_READDATA, upload);
76 /* use active mode FTP */
77 easy_setopt(easy, CURLOPT_FTPPORT, "-");
79 /* server connection timeout */
80 easy_setopt(easy, CURLOPT_ACCEPTTIMEOUT_MS,
81 strtol(libtest_arg2, NULL, 10)*1000);
85 multi_add_handle(multi, easy);
88 struct timeval interval;
95 multi_perform(multi, &running);
97 abort_on_test_timeout();
106 multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
108 /* At this point, maxfd is guaranteed to be greater or equal than -1. */
110 multi_timeout(multi, &timeout);
112 /* At this point, timeout is guaranteed to be greater or equal than -1. */
115 int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
116 interval.tv_sec = itimeout/1000;
117 interval.tv_usec = (itimeout%1000)*1000;
121 interval.tv_usec = 100000L; /* 100 ms */
124 select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &interval);
126 abort_on_test_timeout();
129 msg = curl_multi_info_read(multi, &msgs_left);
131 res = msg->data.result;
135 /* undocumented cleanup sequence - type UA */
137 curl_multi_cleanup(multi);
138 curl_easy_cleanup(easy);
139 curl_global_cleanup();
141 /* close the local file */