1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2012, 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 http://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 */
36 #define TEST_HANG_TIMEOUT 60 * 1000
51 upload = fopen(libtest_arg3, "rb");
54 fprintf(stderr, "fopen() failed with error: %d (%s)\n",
55 error, strerror(error));
56 fprintf(stderr, "Error opening file: (%s)\n", libtest_arg3);
57 return TEST_ERR_FOPEN;
60 res_global_init(CURL_GLOBAL_ALL);
69 easy_setopt(easy, CURLOPT_VERBOSE, 1L);
72 easy_setopt(easy, CURLOPT_URL, URL);
74 /* enable uploading */
75 easy_setopt(easy, CURLOPT_UPLOAD, 1L);
77 /* data pointer for the file read function */
78 easy_setopt(easy, CURLOPT_READDATA, upload);
80 /* use active mode FTP */
81 easy_setopt(easy, CURLOPT_FTPPORT, "-");
83 /* server connection timeout */
84 easy_setopt(easy, CURLOPT_ACCEPTTIMEOUT_MS,
85 strtol(libtest_arg2, NULL, 10)*1000);
89 multi_add_handle(multi, easy);
92 struct timeval interval;
99 multi_perform(multi, &running);
101 abort_on_test_timeout();
110 multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
112 /* At this point, maxfd is guaranteed to be greater or equal than -1. */
114 multi_timeout(multi, &timeout);
116 /* At this point, timeout is guaranteed to be greater or equal than -1. */
119 int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
120 interval.tv_sec = itimeout/1000;
121 interval.tv_usec = (itimeout%1000)*1000;
125 interval.tv_usec = 100000L; /* 100 ms */
128 select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
130 abort_on_test_timeout();
133 msg = curl_multi_info_read(multi, &msgs_left);
135 res = msg->data.result;
139 /* undocumented cleanup sequence - type UA */
141 curl_multi_cleanup(multi);
142 curl_easy_cleanup(easy);
143 curl_global_cleanup();
145 /* close the local file */