libtests: stop checking for CURLM_CALL_MULTI_PERFORM

CURLM_CALL_MULTI_PERFORM stopped being a valid return code from
curl_multi_perform back in 7.20.0. All the libcurl tests are ajusted to
this and no longer check for this return code. Makes them simpler.
This commit is contained in:
Daniel Stenberg 2011-06-26 23:12:08 +02:00
Родитель 78480892cd
Коммит fb48e2050b
13 изменённых файлов: 118 добавлений и 165 удалений

Просмотреть файл

@ -103,18 +103,17 @@ int test(char *URL)
mp_timedout = FALSE; mp_timedout = FALSE;
mp_start = tutil_tvnow(); mp_start = tutil_tvnow();
while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running);
res = (int)curl_multi_perform(m, &running); if (tutil_tvdiff(tutil_tvnow(), mp_start) >
if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE;
mp_timedout = TRUE; break;
break;
}
if (running <= 0) {
done = TRUE;
break;
}
} }
if (running <= 0) {
done = TRUE;
break;
}
if (mp_timedout || done) if (mp_timedout || done)
break; break;
@ -140,7 +139,6 @@ int test(char *URL)
break; break;
} }
res = CURLM_CALL_MULTI_PERFORM;
} }
if (ml_timedout || mp_timedout) { if (ml_timedout || mp_timedout) {

Просмотреть файл

@ -106,15 +106,11 @@ int test(char *URL)
fprintf(stderr, "curl_multi_perform()\n"); fprintf(stderr, "curl_multi_perform()\n");
ret = CURLM_CALL_MULTI_PERFORM; ret = curl_multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
while (ret == CURLM_CALL_MULTI_PERFORM) { MULTI_PERFORM_HANG_TIMEOUT) {
ret = curl_multi_perform(m, &running); mp_timedout = TRUE;
if (tutil_tvdiff(tutil_tvnow(), mp_start) > break;
MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE;
break;
}
} }
if (mp_timedout) if (mp_timedout)
break; break;

Просмотреть файл

@ -75,14 +75,10 @@ int test(char *URL)
mp_timedout = FALSE; mp_timedout = FALSE;
mp_start = tutil_tvnow(); mp_start = tutil_tvnow();
do { ret = curl_multi_perform(multi, &still_running);
ret = curl_multi_perform(multi, &still_running); if (tutil_tvdiff(tutil_tvnow(), mp_start) >
if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT)
MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE;
mp_timedout = TRUE;
break;
}
} while (ret == CURLM_CALL_MULTI_PERFORM);
ml_timedout = FALSE; ml_timedout = FALSE;
ml_start = tutil_tvnow(); ml_start = tutil_tvnow();
@ -116,20 +112,18 @@ int test(char *URL)
default: default:
mp_timedout = FALSE; mp_timedout = FALSE;
mp_start = tutil_tvnow(); mp_start = tutil_tvnow();
do { ret = curl_multi_perform(multi, &still_running);
ret = curl_multi_perform(multi, &still_running); if (tutil_tvdiff(tutil_tvnow(), mp_start) >
if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT)
MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE;
mp_timedout = TRUE;
break;
}
} while (ret == CURLM_CALL_MULTI_PERFORM);
break; break;
} }
} }
if (ml_timedout || mp_timedout) { if (ml_timedout || mp_timedout) {
if (ml_timedout) fprintf(stderr, "ml_timedout\n"); if (ml_timedout)
if (mp_timedout) fprintf(stderr, "mp_timedout\n"); fprintf(stderr, "ml_timedout\n");
if (mp_timedout)
fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems " fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n"); "that it would have run forever.\n");
i = TEST_ERR_RUNS_FOREVER; i = TEST_ERR_RUNS_FOREVER;

Просмотреть файл

@ -151,20 +151,16 @@ int test(char *URL)
mp_timedout = FALSE; mp_timedout = FALSE;
mp_start = tutil_tvnow(); mp_start = tutil_tvnow();
while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running);
res = (int)curl_multi_perform(m, &running); if (tutil_tvdiff(tutil_tvnow(), mp_start) >
if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE;
mp_timedout = TRUE;
break;
}
if (running <= 0) {
done = TRUE;
break;
}
}
if (mp_timedout || done)
break; break;
}
if (running <= 0) {
done = TRUE;
break;
}
if (res != CURLM_OK) { if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n"); fprintf(stderr, "not okay???\n");

Просмотреть файл

@ -149,50 +149,47 @@ int test(char *URL)
mp_timedout = FALSE; mp_timedout = FALSE;
mp_start = tutil_tvnow(); mp_start = tutil_tvnow();
while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running);
res = (int)curl_multi_perform(m, &running); if (tutil_tvdiff(tutil_tvnow(), mp_start) >
if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE;
mp_timedout = TRUE; break;
break; }
} if (running <= 0) {
if (running <= 0) {
#ifdef LIB527 #ifdef LIB527
/* NOTE: this code does not remove the handle from the multi handle /* NOTE: this code does not remove the handle from the multi handle
here, which would be the nice, sane and documented way of working. here, which would be the nice, sane and documented way of working.
This however tests that the API survives this abuse gracefully. */ This however tests that the API survives this abuse gracefully. */
curl_easy_cleanup(curl[current]); curl_easy_cleanup(curl[current]);
#endif #endif
if(++current < NUM_HANDLES) { if(++current < NUM_HANDLES) {
fprintf(stderr, "Advancing to URL %d\n", current); fprintf(stderr, "Advancing to URL %d\n", current);
#ifdef LIB532 #ifdef LIB532
/* first remove the only handle we use */ /* first remove the only handle we use */
curl_multi_remove_handle(m, curl[0]); curl_multi_remove_handle(m, curl[0]);
/* make us re-use the same handle all the time, and try resetting /* make us re-use the same handle all the time, and try resetting
the handle first too */ the handle first too */
curl_easy_reset(curl[0]); curl_easy_reset(curl[0]);
test_setopt(curl[0], CURLOPT_URL, URL); test_setopt(curl[0], CURLOPT_URL, URL);
test_setopt(curl[0], CURLOPT_VERBOSE, 1L); test_setopt(curl[0], CURLOPT_VERBOSE, 1L);
/* re-add it */ /* re-add it */
res = (int)curl_multi_add_handle(m, curl[0]); res = (int)curl_multi_add_handle(m, curl[0]);
#else #else
res = (int)curl_multi_add_handle(m, curl[current]); res = (int)curl_multi_add_handle(m, curl[current]);
#endif #endif
if(res) { if(res) {
fprintf(stderr, "add handle failed: %d.\n", res); fprintf(stderr, "add handle failed: %d.\n", res);
res = 243; res = 243;
break; break;
}
} }
else }
done = TRUE; /* bail out */ else {
done = TRUE; /* bail out */
break; break;
} }
} }
if (mp_timedout || done)
break;
if (res != CURLM_OK) { if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n"); fprintf(stderr, "not okay???\n");
@ -215,8 +212,6 @@ int test(char *URL)
res = 195; res = 195;
break; break;
} }
res = CURLM_CALL_MULTI_PERFORM;
} }
if (ml_timedout || mp_timedout) { if (ml_timedout || mp_timedout) {

Просмотреть файл

@ -161,20 +161,16 @@ int test(char *URL)
mp_timedout = FALSE; mp_timedout = FALSE;
mp_start = tutil_tvnow(); mp_start = tutil_tvnow();
while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running);
res = (int)curl_multi_perform(m, &running); if (tutil_tvdiff(tutil_tvnow(), mp_start) >
if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE;
mp_timedout = TRUE;
break;
}
if (running <= 0) {
done = TRUE; /* bail out */
break;
}
}
if (mp_timedout || done)
break; break;
}
if (running <= 0) {
done = TRUE; /* bail out */
break;
}
if (res != CURLM_OK) { if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n"); fprintf(stderr, "not okay???\n");

Просмотреть файл

@ -99,41 +99,38 @@ int test(char *URL)
mp_timedout = FALSE; mp_timedout = FALSE;
mp_start = tutil_tvnow(); mp_start = tutil_tvnow();
while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running);
res = (int)curl_multi_perform(m, &running); if (tutil_tvdiff(tutil_tvnow(), mp_start) >
if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE;
mp_timedout = TRUE; break;
break; }
} if (running <= 0) {
if (running <= 0) { if(!current++) {
if(!current++) { fprintf(stderr, "Advancing to URL 1\n");
fprintf(stderr, "Advancing to URL 1\n"); /* remove the handle we use */
/* remove the handle we use */ curl_multi_remove_handle(m, curl);
curl_multi_remove_handle(m, curl);
/* make us re-use the same handle all the time, and try resetting /* make us re-use the same handle all the time, and try resetting
the handle first too */ the handle first too */
curl_easy_reset(curl); curl_easy_reset(curl);
test_setopt(curl, CURLOPT_URL, libtest_arg2); test_setopt(curl, CURLOPT_URL, libtest_arg2);
test_setopt(curl, CURLOPT_VERBOSE, 1); test_setopt(curl, CURLOPT_VERBOSE, 1);
test_setopt(curl, CURLOPT_FAILONERROR, 1); test_setopt(curl, CURLOPT_FAILONERROR, 1);
/* re-add it */ /* re-add it */
res = (int)curl_multi_add_handle(m, curl); res = (int)curl_multi_add_handle(m, curl);
if(res) { if(res) {
fprintf(stderr, "add handle failed: %d.\n", res); fprintf(stderr, "add handle failed: %d.\n", res);
res = 243; res = 243;
break; break;
}
} }
else }
done = TRUE; /* bail out */ else {
done = TRUE; /* bail out */
break; break;
} }
} }
if (mp_timedout || done)
break;
if (res != CURLM_OK) { if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n"); fprintf(stderr, "not okay???\n");

Просмотреть файл

@ -59,8 +59,6 @@ static CURLMcode perform(CURLM * multi)
switch (code) { switch (code) {
case CURLM_OK: case CURLM_OK:
break; break;
case CURLM_CALL_MULTI_PERFORM:
continue;
default: default:
return code; return code;
} }

Просмотреть файл

@ -87,9 +87,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd,
while (U) { while (U) {
do { code = curl_multi_perform(cm, &U);
code = curl_multi_perform(cm, &U);
} while (code == CURLM_CALL_MULTI_PERFORM);
if (U) { if (U) {
FD_ZERO(&R); FD_ZERO(&R);

Просмотреть файл

@ -63,9 +63,7 @@ int test(char *URL)
curl_multi_add_handle(multi_handle, http_handle); curl_multi_add_handle(multi_handle, http_handle);
/* we start some action by calling perform right away */ /* we start some action by calling perform right away */
do { code = curl_multi_perform(multi_handle, &still_running);
code = curl_multi_perform(multi_handle, &still_running);
} while(code == CURLM_CALL_MULTI_PERFORM);
while(still_running) { while(still_running) {
struct timeval timeout; struct timeval timeout;
@ -100,9 +98,7 @@ int test(char *URL)
case 0: case 0:
default: default:
/* timeout or readable/writable sockets */ /* timeout or readable/writable sockets */
do { code = curl_multi_perform(multi_handle, &still_running);
code = curl_multi_perform(multi_handle, &still_running);
} while(code == CURLM_CALL_MULTI_PERFORM);
break; break;
} }
} }

Просмотреть файл

@ -98,20 +98,16 @@ int test(char *URL)
mp_timedout = FALSE; mp_timedout = FALSE;
mp_start = tutil_tvnow(); mp_start = tutil_tvnow();
while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running);
res = (int)curl_multi_perform(m, &running); if (tutil_tvdiff(tutil_tvnow(), mp_start) >
if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE;
mp_timedout = TRUE;
break;
}
if (running <= 0) {
done = TRUE; /* bail out */
break;
}
}
if (mp_timedout || done)
break; break;
}
if (running <= 0) {
done = TRUE; /* bail out */
break;
}
if (res != CURLM_OK) { if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n"); fprintf(stderr, "not okay???\n");
@ -134,8 +130,6 @@ int test(char *URL)
res = 195; res = 195;
break; break;
} }
res = CURLM_CALL_MULTI_PERFORM;
} }
if (ml_timedout || mp_timedout) { if (ml_timedout || mp_timedout) {

Просмотреть файл

@ -81,8 +81,7 @@ int test(char *URL)
curl_multi_add_handle(mhandle, handle); curl_multi_add_handle(mhandle, handle);
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(mhandle, &still_running);
curl_multi_perform(mhandle, &still_running));
while(still_running) { while(still_running) {
static struct timeval timeout = /* 100 ms */ { 0, 100000L }; static struct timeval timeout = /* 100 ms */ { 0, 100000L };
@ -108,8 +107,7 @@ int test(char *URL)
goto test_cleanup; goto test_cleanup;
} }
else { else {
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(mhandle, &still_running);
curl_multi_perform(mhandle, &still_running));
} }
} }

Просмотреть файл

@ -182,8 +182,7 @@ static void notifyCurl(CURL* curl, curl_socket_t s, int evBitmask,
{ {
int numhandles = 0; int numhandles = 0;
CURLMcode result = curl_multi_socket_action(curl, s, evBitmask, &numhandles); CURLMcode result = curl_multi_socket_action(curl, s, evBitmask, &numhandles);
if (result != CURLM_OK && result != CURLM_CALL_MULTI_PERFORM) if (result != CURLM_OK) {
{
fprintf(stderr, "Curl error on %s: %i (%s)\n", fprintf(stderr, "Curl error on %s: %i (%s)\n",
info, result, curl_multi_strerror(result)); info, result, curl_multi_strerror(result));
} }
@ -196,10 +195,8 @@ static void checkFdSet(CURL* curl, struct Sockets* sockets, fd_set* fdset,
int evBitmask, const char* name) int evBitmask, const char* name)
{ {
int i; int i;
for (i = 0; i < sockets->count; ++i) for (i = 0; i < sockets->count; ++i) {
{ if (FD_ISSET(sockets->sockets[i], fdset)) {
if (FD_ISSET(sockets->sockets[i], fdset))
{
notifyCurl(curl, sockets->sockets[i], evBitmask, name); notifyCurl(curl, sockets->sockets[i], evBitmask, name);
} }
} }