multi & hiper examples: updates and cleanups

all multi and hiper examples:

* don't loop curl_multi_perform calls, that was <7.20.0 style, currently
  the exported multi functions will not return CURLM_CALL_MULTI_PERFORM

all hiper examples:
* renamed check_run_count to check_multi_info
* don't  compare current running handle count with previous value, this
  was the wrong way to check for finished requests, simply call
  curl_multi_info_read
* it's also safe to call curl_multi_remove_handle inside the
  curl_multi_info_read loop.

ghiper.c:
* replaced curl_multi_socket (that function is marked as obsolete) calls
  with curl_multi_socket_action calls (as in hiperfifo.c and
  evhiperfifo.c)

ghiper.c and evhiperfifo.c:
* be smart as hiperfifo.c, don't do uncessary curl_multi_* calls in
  new_conn and main
This commit is contained in:
Dirk Manske 2010-09-30 11:33:33 +02:00 committed by Daniel Stenberg
parent 67c83eb9eb
commit 5fb4279ec7
10 changed files with 113 additions and 202 deletions

View File

@ -119,7 +119,7 @@ int main(void)
} }
while (U) { while (U) {
while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(cm, &U)); curl_multi_perform(cm, &U);
if (U) { if (U) {
FD_ZERO(&R); FD_ZERO(&R);

View File

@ -68,7 +68,6 @@ typedef struct _GlobalInfo
struct ev_io fifo_event; struct ev_io fifo_event;
struct ev_timer timer_event; struct ev_timer timer_event;
CURLM *multi; CURLM *multi;
int prev_running;
int still_running; int still_running;
FILE* input; FILE* input;
} GlobalInfo; } GlobalInfo;
@ -122,7 +121,6 @@ static void mcode_or_die(const char *where, CURLMcode code)
switch ( code ) switch ( code )
{ {
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break; case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
case CURLM_OK: s="CURLM_OK"; break;
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break; case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break; case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break; case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
@ -144,54 +142,33 @@ static void mcode_or_die(const char *where, CURLMcode code)
/* Check for completed transfers, and remove their easy handles */ /* Check for completed transfers, and remove their easy handles */
static void check_run_count(GlobalInfo *g) static void check_multi_info(GlobalInfo *g)
{ {
DPRINT("%s prev %i still %i\n", __PRETTY_FUNCTION__, char *eff_url;
g->prev_running, g->still_running); CURLMsg *msg;
if ( g->prev_running > g->still_running ) int msgs_left;
{ ConnInfo *conn;
char *eff_url=NULL; CURL *easy;
CURLMsg *msg; CURLcode res;
int msgs_left;
ConnInfo *conn=NULL;
CURL*easy;
CURLcode res;
fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running); fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running);
/* while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
I am still uncertain whether it is safe to remove an easy if (msg->msg == CURLMSG_DONE) {
handle from inside the curl_multi_info_read loop, so here I easy = msg->easy_handle;
will search for completed transfers in the inner "while" res = msg->data.result;
loop, and then remove them in the outer "do-while" loop... curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
*/ curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
do fprintf(MSG_OUT, "DONE: %s => (%d) %s\n", eff_url, res, conn->error);
{ curl_multi_remove_handle(g->multi, easy);
easy=NULL; free(conn->url);
while ( (msg = curl_multi_info_read(g->multi, &msgs_left)) ) curl_easy_cleanup(easy);
{ free(conn);
if ( msg->msg == CURLMSG_DONE ) }
{
easy=msg->easy_handle;
res=msg->data.result;
}
if ( easy )
{
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
fprintf(MSG_OUT, "DONE: %s => (%d) %s\n", eff_url, res, conn->error);
curl_multi_remove_handle(g->multi, easy);
free(conn->url);
curl_easy_cleanup(easy);
free(conn);
}
}
} while ( easy );
} }
g->prev_running = g->still_running;
} }
/* Called by libevent when we get action on a multi socket */ /* Called by libevent when we get action on a multi socket */
static void event_cb(EV_P_ struct ev_io *w, int revents) static void event_cb(EV_P_ struct ev_io *w, int revents)
{ {
@ -201,12 +178,9 @@ static void event_cb(EV_P_ struct ev_io *w, int revents)
int action = (revents&EV_READ?CURL_POLL_IN:0)| int action = (revents&EV_READ?CURL_POLL_IN:0)|
(revents&EV_WRITE?CURL_POLL_OUT:0); (revents&EV_WRITE?CURL_POLL_OUT:0);
do rc = curl_multi_socket_action(g->multi, w->fd, action, &g->still_running);
{ mcode_or_die("event_cb: curl_multi_socket_action", rc);
rc = curl_multi_socket_action(g->multi, w->fd, action, &g->still_running); check_multi_info(g);
} while ( rc == CURLM_CALL_MULTI_PERFORM );
mcode_or_die("event_cb: curl_multi_socket", rc);
check_run_count(g);
if ( g->still_running <= 0 ) if ( g->still_running <= 0 )
{ {
fprintf(MSG_OUT, "last transfer done, kill timeout\n"); fprintf(MSG_OUT, "last transfer done, kill timeout\n");
@ -222,12 +196,9 @@ static void timer_cb(EV_P_ struct ev_timer *w, int revents)
GlobalInfo *g = (GlobalInfo *)w->data; GlobalInfo *g = (GlobalInfo *)w->data;
CURLMcode rc; CURLMcode rc;
do rc = curl_multi_socket_action(g->multi, CURL_SOCKET_TIMEOUT, 0, &g->still_running);
{ mcode_or_die("timer_cb: curl_multi_socket_action", rc);
rc = curl_multi_socket_action(g->multi, CURL_SOCKET_TIMEOUT, 0, &g->still_running); check_multi_info(g);
} while ( rc == CURLM_CALL_MULTI_PERFORM );
mcode_or_die("timer_cb: curl_multi_socket", rc);
check_run_count(g);
} }
/* Clean up the SockInfo structure */ /* Clean up the SockInfo structure */
@ -364,11 +335,11 @@ static void new_conn(char *url, GlobalInfo *g )
fprintf(MSG_OUT, fprintf(MSG_OUT,
"Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url); "Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
rc =curl_multi_add_handle(g->multi, conn->easy); rc = curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc); mcode_or_die("new_conn: curl_multi_add_handle", rc);
mcode_or_die("new_conn: curl_multi_socket_all", rc); /* note that the add_handle() will set a time-out to trigger very soon so
check_run_count(g); that the necessary socket_action() call will be called by this app */
} }
/* This gets called whenever data is received from the fifo */ /* This gets called whenever data is received from the fifo */
@ -448,10 +419,9 @@ int main(int argc, char **argv)
curl_multi_setopt(g.multi, CURLMOPT_SOCKETDATA, &g); curl_multi_setopt(g.multi, CURLMOPT_SOCKETDATA, &g);
curl_multi_setopt(g.multi, CURLMOPT_TIMERFUNCTION, multi_timer_cb); curl_multi_setopt(g.multi, CURLMOPT_TIMERFUNCTION, multi_timer_cb);
curl_multi_setopt(g.multi, CURLMOPT_TIMERDATA, &g); curl_multi_setopt(g.multi, CURLMOPT_TIMERDATA, &g);
do
{ /* we don't call any curl_multi_socket*() function yet as we have no handles
rc = curl_multi_socket_all(g.multi, &g.still_running); added! */
} while ( CURLM_CALL_MULTI_PERFORM == rc );
ev_loop(g.loop, 0); ev_loop(g.loop, 0);
curl_multi_cleanup(g.multi); curl_multi_cleanup(g.multi);

View File

@ -184,12 +184,7 @@ fill_buffer(URL_FILE *file,int want,int waittime)
default: default:
/* timeout or readable/writable sockets */ /* timeout or readable/writable sockets */
/* note we *could* be more efficient and not wait for curl_multi_perform(multi_handle, &file->still_running);
* CURLM_CALL_MULTI_PERFORM to clear here and check it on re-entry
* but that gets messy */
while(curl_multi_perform(multi_handle, &file->still_running) ==
CURLM_CALL_MULTI_PERFORM);
break; break;
} }
} while(file->still_running && (file->buffer_pos < want)); } while(file->still_running && (file->buffer_pos < want));
@ -260,8 +255,7 @@ url_fopen(const char *url,const char *operation)
curl_multi_add_handle(multi_handle, file->handle.curl); curl_multi_add_handle(multi_handle, file->handle.curl);
/* lets start the fetch */ /* lets start the fetch */
while(curl_multi_perform(multi_handle, &file->still_running) == curl_multi_perform(multi_handle, &file->still_running);
CURLM_CALL_MULTI_PERFORM );
if((file->buffer_pos == 0) && (!file->still_running)) if((file->buffer_pos == 0) && (!file->still_running))
{ {

View File

@ -58,10 +58,7 @@ callback.
typedef struct _GlobalInfo { typedef struct _GlobalInfo {
CURLM *multi; CURLM *multi;
guint timer_event; guint timer_event;
int prev_running;
int still_running; int still_running;
int requested; /* count: curl_easy_init() */
int completed; /* count: curl_easy_cleanup() */
} GlobalInfo; } GlobalInfo;
@ -95,7 +92,6 @@ static void mcode_or_die(const char *where, CURLMcode code) {
const char *s; const char *s;
switch (code) { switch (code) {
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break; case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
case CURLM_OK: s="CURLM_OK"; break;
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break; case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break; case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break; case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
@ -113,62 +109,43 @@ static void mcode_or_die(const char *where, CURLMcode code) {
/* Check for completed transfers, and remove their easy handles */ /* Check for completed transfers, and remove their easy handles */
static void check_run_count(GlobalInfo *g) static void check_multi_info(GlobalInfo *g)
{ {
if (g->prev_running > g->still_running) { char *eff_url;
char *eff_url=NULL; CURLMsg *msg;
CURLMsg *msg; int msgs_left;
int msgs_left; ConnInfo *conn;
ConnInfo *conn=NULL; CURL *easy;
CURL*easy; CURLcode res;
CURLcode res;
MSG_OUT("REMAINING: %d\n", g->still_running); MSG_OUT("REMAINING: %d\n", g->still_running);
/* while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
I am still uncertain whether it is safe to remove an easy handle if (msg->msg == CURLMSG_DONE) {
from inside the curl_multi_info_read loop, so here I will search easy = msg->easy_handle;
for completed transfers in the inner "while" loop, and then remove res = msg->data.result;
them in the outer "do-while" loop... curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
*/ curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
do { MSG_OUT("DONE: %s => (%d) %s\n", eff_url, res, conn->error);
easy=NULL; curl_multi_remove_handle(g->multi, easy);
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) { free(conn->url);
if (msg->msg == CURLMSG_DONE) { curl_easy_cleanup(easy);
easy=msg->easy_handle; free(conn);
res=msg->data.result; }
break;
}
}
if (easy) {
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
MSG_OUT("DONE: %s => (%d) %s\n", eff_url, res, conn->error);
curl_multi_remove_handle(g->multi, easy);
g_free(conn->url);
curl_easy_cleanup(easy);
g_free(conn);
g->completed++;
}
} while ( easy );
MSG_OUT("Requested: %d Completed:%d\n", g->requested, g->completed);
} }
g->prev_running = g->still_running;
} }
/* Called by glib when our timeout expires */ /* Called by glib when our timeout expires */
static gboolean timer_cb(gpointer data) static gboolean timer_cb(gpointer data)
{ {
GlobalInfo *g = (GlobalInfo *)data; GlobalInfo *g = (GlobalInfo *)data;
CURLMcode rc; CURLMcode rc;
do { rc = curl_multi_socket_action(g->multi,
rc = curl_multi_socket(g->multi, CURL_SOCKET_TIMEOUT, &g->still_running); CURL_SOCKET_TIMEOUT, 0, &g->still_running);
} while (rc == CURLM_CALL_MULTI_PERFORM); mcode_or_die("timer_cb: curl_multi_socket_action", rc);
mcode_or_die("timer_cb: curl_multi_socket", rc); check_multi_info(g);
check_run_count(g);
return FALSE; return FALSE;
} }
@ -198,11 +175,15 @@ static gboolean event_cb(GIOChannel *ch, GIOCondition condition, gpointer data)
GlobalInfo *g = (GlobalInfo*) data; GlobalInfo *g = (GlobalInfo*) data;
CURLMcode rc; CURLMcode rc;
int fd=g_io_channel_unix_get_fd(ch); int fd=g_io_channel_unix_get_fd(ch);
do {
rc = curl_multi_socket(g->multi, fd, &g->still_running); int action =
} while (rc == CURLM_CALL_MULTI_PERFORM); (condition & G_IO_IN ? CURL_CSELECT_IN : 0) |
mcode_or_die("event_cb: curl_multi_socket", rc); (condition & G_IO_OUT ? CURL_CSELECT_OUT : 0);
check_run_count(g);
rc = curl_multi_socket_action(g->multi, fd, action, &g->still_running);
mcode_or_die("event_cb: curl_multi_socket_action", rc);
check_multi_info(g);
if(g->still_running) { if(g->still_running) {
return TRUE; return TRUE;
} else { } else {
@ -338,12 +319,9 @@ static void new_conn(char *url, GlobalInfo *g )
MSG_OUT("Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url); MSG_OUT("Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
rc =curl_multi_add_handle(g->multi, conn->easy); rc =curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc); mcode_or_die("new_conn: curl_multi_add_handle", rc);
g->requested++;
do { /* note that the add_handle() will set a time-out to trigger very soon so
rc = curl_multi_socket_all(g->multi, &g->still_running); that the necessary socket_action() call will be called by this app */
} while (CURLM_CALL_MULTI_PERFORM == rc);
mcode_or_die("new_conn: curl_multi_socket_all", rc);
check_run_count(g);
} }
@ -451,9 +429,10 @@ int main(int argc, char **argv)
curl_multi_setopt(g->multi, CURLMOPT_SOCKETDATA, g); curl_multi_setopt(g->multi, CURLMOPT_SOCKETDATA, g);
curl_multi_setopt(g->multi, CURLMOPT_TIMERFUNCTION, update_timeout_cb); curl_multi_setopt(g->multi, CURLMOPT_TIMERFUNCTION, update_timeout_cb);
curl_multi_setopt(g->multi, CURLMOPT_TIMERDATA, g); curl_multi_setopt(g->multi, CURLMOPT_TIMERDATA, g);
do {
rc = curl_multi_socket_all(g->multi, &g->still_running); /* we don't call any curl_multi_socket*() function yet as we have no handles
} while (CURLM_CALL_MULTI_PERFORM == rc); added! */
g_main_loop_run(gmain); g_main_loop_run(gmain);
curl_multi_cleanup(g->multi); curl_multi_cleanup(g->multi);
return 0; return 0;

View File

@ -62,7 +62,6 @@ typedef struct _GlobalInfo {
struct event fifo_event; struct event fifo_event;
struct event timer_event; struct event timer_event;
CURLM *multi; CURLM *multi;
int prev_running;
int still_running; int still_running;
FILE* input; FILE* input;
} GlobalInfo; } GlobalInfo;
@ -110,7 +109,6 @@ static void mcode_or_die(const char *where, CURLMcode code)
const char *s; const char *s;
switch (code) { switch (code) {
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break; case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
case CURLM_OK: s="CURLM_OK"; break;
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break; case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break; case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break; case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
@ -132,44 +130,29 @@ static void mcode_or_die(const char *where, CURLMcode code)
/* Check for completed transfers, and remove their easy handles */ /* Check for completed transfers, and remove their easy handles */
static void check_run_count(GlobalInfo *g) static void check_multi_info(GlobalInfo *g)
{ {
if (g->prev_running > g->still_running) { char *eff_url;
char *eff_url=NULL; CURLMsg *msg;
CURLMsg *msg; int msgs_left;
int msgs_left; ConnInfo *conn;
ConnInfo *conn=NULL; CURL *easy;
CURL*easy; CURLcode res;
CURLcode res;
fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running); fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running);
/* while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
I am still uncertain whether it is safe to remove an easy handle if (msg->msg == CURLMSG_DONE) {
from inside the curl_multi_info_read loop, so here I will search easy = msg->easy_handle;
for completed transfers in the inner "while" loop, and then remove res = msg->data.result;
them in the outer "do-while" loop... curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
*/ curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
do { fprintf(MSG_OUT, "DONE: %s => (%d) %s\n", eff_url, res, conn->error);
easy=NULL; curl_multi_remove_handle(g->multi, easy);
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) { free(conn->url);
if (msg->msg == CURLMSG_DONE) { curl_easy_cleanup(easy);
easy=msg->easy_handle; free(conn);
res=msg->data.result; }
break;
}
}
if (easy) {
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
fprintf(MSG_OUT, "DONE: %s => (%d) %s\n", eff_url, res, conn->error);
curl_multi_remove_handle(g->multi, easy);
free(conn->url);
curl_easy_cleanup(easy);
free(conn);
}
} while ( easy );
} }
g->prev_running = g->still_running;
} }
@ -181,16 +164,13 @@ static void event_cb(int fd, short kind, void *userp)
CURLMcode rc; CURLMcode rc;
int action = int action =
(kind&EV_READ?CURL_CSELECT_IN:0)| (kind & EV_READ ? CURL_CSELECT_IN : 0) |
(kind&EV_WRITE?CURL_CSELECT_OUT:0); (kind & EV_WRITE ? CURL_CSELECT_OUT : 0);
do {
rc = curl_multi_socket_action(g->multi, fd, action, &g->still_running);
} while (rc == CURLM_CALL_MULTI_PERFORM);
rc = curl_multi_socket_action(g->multi, fd, action, &g->still_running);
mcode_or_die("event_cb: curl_multi_socket_action", rc); mcode_or_die("event_cb: curl_multi_socket_action", rc);
check_run_count(g); check_multi_info(g);
if ( g->still_running <= 0 ) { if ( g->still_running <= 0 ) {
fprintf(MSG_OUT, "last transfer done, kill timeout\n"); fprintf(MSG_OUT, "last transfer done, kill timeout\n");
if (evtimer_pending(&g->timer_event, NULL)) { if (evtimer_pending(&g->timer_event, NULL)) {
@ -209,12 +189,10 @@ static void timer_cb(int fd, short kind, void *userp)
(void)fd; (void)fd;
(void)kind; (void)kind;
do { rc = curl_multi_socket_action(g->multi,
rc = curl_multi_socket_action(g->multi,
CURL_SOCKET_TIMEOUT, 0, &g->still_running); CURL_SOCKET_TIMEOUT, 0, &g->still_running);
} while (rc == CURLM_CALL_MULTI_PERFORM);
mcode_or_die("timer_cb: curl_multi_socket_action", rc); mcode_or_die("timer_cb: curl_multi_socket_action", rc);
check_run_count(g); check_multi_info(g);
} }
@ -340,7 +318,7 @@ static void new_conn(char *url, GlobalInfo *g )
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSDATA, conn); curl_easy_setopt(conn->easy, CURLOPT_PROGRESSDATA, conn);
fprintf(MSG_OUT, fprintf(MSG_OUT,
"Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url); "Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
rc =curl_multi_add_handle(g->multi, conn->easy); rc = curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc); mcode_or_die("new_conn: curl_multi_add_handle", rc);
/* note that the add_handle() will set a time-out to trigger very soon so /* note that the add_handle() will set a time-out to trigger very soon so

View File

@ -56,8 +56,7 @@ int main(int argc, char **argv)
curl_multi_add_handle(multi_handle, handles[i]); curl_multi_add_handle(multi_handle, handles[i]);
/* we start some action by calling perform right away */ /* we start some action by calling perform right away */
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, &still_running);
curl_multi_perform(multi_handle, &still_running));
while(still_running) { while(still_running) {
struct timeval timeout; struct timeval timeout;
@ -108,8 +107,7 @@ int main(int argc, char **argv)
default: default:
/* one or more of curl's file descriptors say there's data to read /* one or more of curl's file descriptors say there's data to read
or write */ or write */
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, &still_running);
curl_multi_perform(multi_handle, &still_running));
break; break;
} }
} }

View File

@ -130,8 +130,7 @@ int main(int argc, char **argv)
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 */
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, &still_running);
curl_multi_perform(multi_handle, &still_running));
while(still_running) { while(still_running) {
struct timeval timeout; struct timeval timeout;
@ -181,8 +180,7 @@ int main(int argc, char **argv)
case 0: case 0:
default: default:
/* timeout or readable/writable sockets */ /* timeout or readable/writable sockets */
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, &still_running);
curl_multi_perform(multi_handle, &still_running));
break; break;
} }
} }

View File

@ -47,8 +47,7 @@ int main(int argc, char **argv)
curl_multi_add_handle(multi_handle, http_handle2); curl_multi_add_handle(multi_handle, http_handle2);
/* we start some action by calling perform right away */ /* we start some action by calling perform right away */
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, &still_running);
curl_multi_perform(multi_handle, &still_running));
while(still_running) { while(still_running) {
struct timeval timeout; struct timeval timeout;
@ -96,8 +95,7 @@ int main(int argc, char **argv)
case 0: case 0:
default: default:
/* timeout or readable/writable sockets */ /* timeout or readable/writable sockets */
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, &still_running);
curl_multi_perform(multi_handle, &still_running));
break; break;
} }
} }

View File

@ -67,8 +67,7 @@ int main(int argc, char *argv[])
curl_multi_add_handle(multi_handle, curl); curl_multi_add_handle(multi_handle, curl);
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, &still_running);
curl_multi_perform(multi_handle, &still_running));
while(still_running) { while(still_running) {
struct timeval timeout; struct timeval timeout;
@ -118,8 +117,7 @@ int main(int argc, char *argv[])
default: default:
/* timeout or readable/writable sockets */ /* timeout or readable/writable sockets */
printf("perform!\n"); printf("perform!\n");
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, &still_running);
curl_multi_perform(multi_handle, &still_running));
printf("running: %d!\n", still_running); printf("running: %d!\n", still_running);
break; break;
} }

View File

@ -41,8 +41,7 @@ int main(int argc, char **argv)
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 */
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, &still_running);
curl_multi_perform(multi_handle, &still_running));
while(still_running) { while(still_running) {
struct timeval timeout; struct timeval timeout;
@ -92,8 +91,7 @@ int main(int argc, char **argv)
case 0: case 0:
default: default:
/* timeout or readable/writable sockets */ /* timeout or readable/writable sockets */
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle, &still_running);
curl_multi_perform(multi_handle, &still_running));
break; break;
} }
} }