1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 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 ***************************************************************************/
30 #define TEST_HANG_TIMEOUT 5 * 1000
33 * Test case for below scenario:
34 * - Connect to an FTP server using CONNECT_ONLY option
35 * - transfer some files with re-using the connection (omitted in test case)
36 * - Disconnect from FTP server with sending QUIT command
38 * The test case originated for verifying CONNECT_ONLY option shall not
39 * block after protocol connect is done, but it returns the message
40 * with function curl_multi_info_read().
44 CONNECT_ONLY_PHASE = 0,
61 global_init(CURL_GLOBAL_ALL);
67 for(phase = CONNECT_ONLY_PHASE; phase < LAST_PHASE; ++phase) {
69 easy_setopt(easy, CURLOPT_VERBOSE, 1L);
72 easy_setopt(easy, CURLOPT_URL, URL);
74 /* enable 'CONNECT_ONLY' option when in connect phase */
75 if(phase == CONNECT_ONLY_PHASE)
76 easy_setopt(easy, CURLOPT_CONNECT_ONLY, 1L);
78 /* enable 'NOBODY' option to send 'QUIT' command in quit phase */
79 if(phase == QUIT_PHASE) {
80 easy_setopt(easy, CURLOPT_CONNECT_ONLY, 0L);
81 easy_setopt(easy, CURLOPT_NOBODY, 1L);
82 easy_setopt(easy, CURLOPT_FORBID_REUSE, 1L);
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
116 int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
117 interval.tv_sec = itimeout/1000;
118 interval.tv_usec = (itimeout%1000)*1000;
121 interval.tv_sec = TEST_HANG_TIMEOUT/1000 + 1;
122 interval.tv_usec = 0;
125 select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &interval);
127 abort_on_test_timeout();
130 msg = curl_multi_info_read(multi, &msgs_left);
132 res = msg->data.result;
134 multi_remove_handle(multi, easy);
139 /* undocumented cleanup sequence - type UA */
141 curl_multi_cleanup(multi);
142 curl_easy_cleanup(easy);
143 curl_global_cleanup();