Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "test.h"
00023
00024 #include "testutil.h"
00025 #include "warnless.h"
00026 #include "memdebug.h"
00027
00028 #define TEST_HANG_TIMEOUT 60 * 1000
00029
00030 #define NUM_HANDLES 4
00031
00032 int test(char *URL)
00033 {
00034 int res = 0;
00035 CURL *curl[NUM_HANDLES] = {0};
00036 int running;
00037 CURLM *m = NULL;
00038 int i;
00039 char target_url[256];
00040 char dnsentry[256];
00041 struct curl_slist *slist = NULL, *slist2;
00042 char *port = libtest_arg3;
00043 char *address = libtest_arg2;
00044
00045 (void)URL;
00046
00047
00048 for(i=0; i < NUM_HANDLES; i++) {
00049 snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s",
00050 i + 1, port, address);
00051 printf("%s\n", dnsentry);
00052 slist2 = curl_slist_append(slist, dnsentry);
00053 if(!slist2) {
00054 fprintf(stderr, "curl_slist_append() failed\n");
00055 goto test_cleanup;
00056 }
00057 slist = slist2;
00058 }
00059
00060 start_test_timing();
00061
00062 global_init(CURL_GLOBAL_ALL);
00063
00064 multi_init(m);
00065
00066 multi_setopt(m, CURLMOPT_MAXCONNECTS, 3L);
00067
00068
00069 for(i=0; i < NUM_HANDLES; i++) {
00070
00071 easy_init(curl[i]);
00072
00073 snprintf(target_url, sizeof(target_url),
00074 "http://server%d.example.com:%s/path/1506%04i",
00075 i + 1, port, i + 1);
00076 target_url[sizeof(target_url) - 1] = '\0';
00077 easy_setopt(curl[i], CURLOPT_URL, target_url);
00078
00079 easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
00080
00081 easy_setopt(curl[i], CURLOPT_HEADER, 1L);
00082
00083 easy_setopt(curl[i], CURLOPT_RESOLVE, slist);
00084 }
00085
00086 fprintf(stderr, "Start at URL 0\n");
00087
00088 for(i=0; i < NUM_HANDLES; i++) {
00089
00090 multi_add_handle(m, curl[i]);
00091
00092 for(;;) {
00093 struct timeval interval;
00094 fd_set rd, wr, exc;
00095 int maxfd = -99;
00096
00097 interval.tv_sec = 1;
00098 interval.tv_usec = 0;
00099
00100 multi_perform(m, &running);
00101
00102 abort_on_test_timeout();
00103
00104 if(!running)
00105 break;
00106
00107 FD_ZERO(&rd);
00108 FD_ZERO(&wr);
00109 FD_ZERO(&exc);
00110
00111 multi_fdset(m, &rd, &wr, &exc, &maxfd);
00112
00113
00114
00115 select_test(maxfd+1, &rd, &wr, &exc, &interval);
00116
00117 abort_on_test_timeout();
00118 }
00119 wait_ms(1);
00120 }
00121
00122 test_cleanup:
00123
00124
00125
00126 for(i=0; i < NUM_HANDLES; i++) {
00127 curl_multi_remove_handle(m, curl[i]);
00128 curl_easy_cleanup(curl[i]);
00129 }
00130
00131 curl_slist_free_all(slist);
00132
00133 curl_multi_cleanup(m);
00134 curl_global_cleanup();
00135
00136 return res;
00137 }