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 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 ***************************************************************************/
32 #define TEST_HANG_TIMEOUT 5 * 1000
35 * Test case for below scenario:
36 * - Connect to an FTP server using CONNECT_ONLY option
37 * - transfer some files with re-using the connection (omitted in test case)
38 * - Disconnect from FTP server with sending QUIT command
40 * The test case originated for verifying CONNECT_ONLY option shall not
41 * block after protocol connect is done, but it returns the message
42 * with function curl_multi_info_read().
46 CONNECT_ONLY_PHASE = 0,
63 res_global_init(CURL_GLOBAL_ALL);
72 for (phase = CONNECT_ONLY_PHASE; phase < LAST_PHASE; ++phase) {
74 easy_setopt(easy, CURLOPT_VERBOSE, 1L);
77 easy_setopt(easy, CURLOPT_URL, URL);
79 /* enable 'CONNECT_ONLY' option when in connect phase */
80 if (phase == CONNECT_ONLY_PHASE)
81 easy_setopt(easy, CURLOPT_CONNECT_ONLY, 1L);
83 /* enable 'NOBODY' option to send 'QUIT' command in quit phase */
84 if (phase == QUIT_PHASE) {
85 easy_setopt(easy, CURLOPT_CONNECT_ONLY, 0L);
86 easy_setopt(easy, CURLOPT_NOBODY, 1L);
87 easy_setopt(easy, CURLOPT_FORBID_REUSE, 1L);
90 multi_add_handle(multi, easy);
93 struct timeval interval;
100 multi_perform(multi, &running);
102 abort_on_test_timeout();
111 multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
113 /* At this point, maxfd is guaranteed to be greater or equal than -1. */
115 multi_timeout(multi, &timeout);
117 /* At this point, timeout is guaranteed to be greater or equal than -1. */
120 int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
121 interval.tv_sec = itimeout/1000;
122 interval.tv_usec = (itimeout%1000)*1000;
125 interval.tv_sec = TEST_HANG_TIMEOUT/1000+1;
126 interval.tv_usec = 0;
129 select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
131 abort_on_test_timeout();
134 msg = curl_multi_info_read(multi, &msgs_left);
136 res = msg->data.result;
138 multi_remove_handle(multi, easy);
143 /* undocumented cleanup sequence - type UA */
145 curl_multi_cleanup(multi);
146 curl_easy_cleanup(easy);
147 curl_global_cleanup();