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];
00036 int running;
00037 CURLM *m = NULL;
00038 int i;
00039 char target_url[256];
00040 int handles_added = 0;
00041
00042 for(i=0; i < NUM_HANDLES; i++)
00043 curl[i] = NULL;
00044
00045 start_test_timing();
00046
00047 global_init(CURL_GLOBAL_ALL);
00048
00049 multi_init(m);
00050
00051
00052 for(i=0; i < NUM_HANDLES; i++) {
00053
00054 easy_init(curl[i]);
00055
00056 snprintf(target_url, sizeof(target_url), "%s%04i", URL, i + 1);
00057 target_url[sizeof(target_url) - 1] = '\0';
00058 easy_setopt(curl[i], CURLOPT_URL, target_url);
00059
00060 easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
00061
00062 easy_setopt(curl[i], CURLOPT_HEADER, 1L);
00063 }
00064
00065
00066
00067
00068 multi_add_handle(m, curl[handles_added++]);
00069
00070 multi_setopt(m, CURLMOPT_PIPELINING, 1L);
00071
00072 fprintf(stderr, "Start at URL 0\n");
00073
00074 for(;;) {
00075 struct timeval interval;
00076 fd_set rd, wr, exc;
00077 int maxfd = -99;
00078
00079 interval.tv_sec = 1;
00080 interval.tv_usec = 0;
00081
00082 multi_perform(m, &running);
00083
00084 abort_on_test_timeout();
00085
00086 if(!running) {
00087 if(handles_added >= NUM_HANDLES)
00088 break;
00089
00090
00091
00092 while(handles_added < NUM_HANDLES)
00093 multi_add_handle(m, curl[handles_added++]);
00094 }
00095
00096 FD_ZERO(&rd);
00097 FD_ZERO(&wr);
00098 FD_ZERO(&exc);
00099
00100 multi_fdset(m, &rd, &wr, &exc, &maxfd);
00101
00102
00103
00104 select_test(maxfd+1, &rd, &wr, &exc, &interval);
00105
00106 abort_on_test_timeout();
00107 }
00108
00109 test_cleanup:
00110
00111
00112
00113 for(i=0; i < NUM_HANDLES; i++) {
00114 curl_multi_remove_handle(m, curl[i]);
00115 curl_easy_cleanup(curl[i]);
00116 }
00117
00118 curl_multi_cleanup(m);
00119 curl_global_cleanup();
00120
00121 return res;
00122 }