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 ***************************************************************************/
28 #define TEST_HANG_TIMEOUT 60 * 1000
35 CURL *curl[NUM_HANDLES];
40 int handles_added = 0;
42 for(i=0; i < NUM_HANDLES; i++)
47 global_init(CURL_GLOBAL_ALL);
51 /* get NUM_HANDLES easy handles */
52 for(i=0; i < NUM_HANDLES; i++) {
53 /* get an easy handle */
56 sprintf(target_url, "%s%04i", URL, i + 1);
57 target_url[sizeof(target_url) - 1] = '\0';
58 easy_setopt(curl[i], CURLOPT_URL, target_url);
60 easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
62 easy_setopt(curl[i], CURLOPT_HEADER, 1L);
65 /* Add the first handle to multi. We do this to let libcurl detect
66 that the server can do pipelining. The rest of the handles will be
68 multi_add_handle(m, curl[handles_added++]);
70 multi_setopt(m, CURLMOPT_PIPELINING, 1L);
72 fprintf(stderr, "Start at URL 0\n");
75 struct timeval interval;
82 multi_perform(m, &running);
84 abort_on_test_timeout();
86 if(!running && handles_added >= NUM_HANDLES)
89 /* Add the rest of the handles now that the first handle has sent the
91 while(handles_added < NUM_HANDLES)
92 multi_add_handle(m, curl[handles_added++]);
98 multi_fdset(m, &rd, &wr, &exc, &maxfd);
100 /* At this point, maxfd is guaranteed to be greater or equal than -1. */
102 select_test(maxfd+1, &rd, &wr, &exc, &interval);
104 abort_on_test_timeout();
109 /* proper cleanup sequence - type PB */
111 for(i=0; i < NUM_HANDLES; i++) {
112 curl_multi_remove_handle(m, curl[i]);
113 curl_easy_cleanup(curl[i]);
116 curl_multi_cleanup(m);
117 curl_global_cleanup();