1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 2013, Linus Nielsen Feltzing <linus@haxx.se>
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 ***************************************************************************/
28 #define TEST_HANG_TIMEOUT 60 * 1000
35 CURL *curl[NUM_HANDLES] = {0};
41 struct curl_slist *slist = NULL, *slist2;
42 char *port = libtest_arg3;
43 char *address = libtest_arg2;
47 /* Create fake DNS entries for serverX.example.com for all handles */
48 for(i=0; i < NUM_HANDLES; i++) {
49 sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
50 printf("%s\n", dnsentry);
51 slist2 = curl_slist_append(slist, dnsentry);
53 fprintf(stderr, "curl_slist_append() failed\n");
61 global_init(CURL_GLOBAL_ALL);
65 multi_setopt(m, CURLMOPT_MAXCONNECTS, 3L);
67 /* get NUM_HANDLES easy handles */
68 for(i=0; i < NUM_HANDLES; i++) {
69 /* get an easy handle */
72 sprintf(target_url, "http://server%d.example.com:%s/path/1506%04i",
74 target_url[sizeof(target_url) - 1] = '\0';
75 easy_setopt(curl[i], CURLOPT_URL, target_url);
77 easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
79 easy_setopt(curl[i], CURLOPT_HEADER, 1L);
81 easy_setopt(curl[i], CURLOPT_RESOLVE, slist);
84 fprintf(stderr, "Start at URL 0\n");
86 for(i=0; i < NUM_HANDLES; i++) {
87 /* add handle to multi */
88 multi_add_handle(m, curl[i]);
91 struct timeval interval;
98 multi_perform(m, &running);
100 abort_on_test_timeout();
109 multi_fdset(m, &rd, &wr, &exc, &maxfd);
111 /* At this point, maxfd is guaranteed to be greater or equal than -1. */
113 select_test(maxfd+1, &rd, &wr, &exc, &interval);
115 abort_on_test_timeout();
117 wait_ms(1); /* to ensure different end times */
122 /* proper cleanup sequence - type PB */
124 for(i=0; i < NUM_HANDLES; i++) {
125 curl_multi_remove_handle(m, curl[i]);
126 curl_easy_cleanup(curl[i]);
129 curl_slist_free_all(slist);
131 curl_multi_cleanup(m);
132 curl_global_cleanup();