1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2011, 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 ***************************************************************************/
30 #define TEST_HANG_TIMEOUT 60 * 1000
32 static int perform(CURLM *multi)
35 fd_set fdread, fdwrite, fdexcep;
39 struct timeval interval;
43 interval.tv_usec = 100000L; /* 100 ms */
45 res_multi_perform(multi, &handles);
60 res_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
64 /* At this point, maxfd is guaranteed to be greater or equal than -1. */
66 res_select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
75 return 0; /* success */
86 global_init(CURL_GLOBAL_ALL);
92 multi_setopt(multi, CURLMOPT_PIPELINING, 1L);
94 easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
95 easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
96 easy_setopt(easy, CURLOPT_URL, URL);
98 res_multi_add_handle(multi, easy);
100 printf("curl_multi_add_handle() 1 failed\n");
104 res = perform(multi);
106 printf("retrieve 1 failed\n");
110 curl_multi_remove_handle(multi, easy);
112 curl_easy_reset(easy);
114 easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
115 easy_setopt(easy, CURLOPT_URL, libtest_arg2);
117 res_multi_add_handle(multi, easy);
119 printf("curl_multi_add_handle() 2 failed\n");
123 res = perform(multi);
125 printf("retrieve 2 failed\n");
129 curl_multi_remove_handle(multi, easy);
133 /* undocumented cleanup sequence - type UB */
135 curl_easy_cleanup(easy);
136 curl_multi_cleanup(multi);
137 curl_global_cleanup();
139 printf("Finished!\n");