112
111
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
113
case CURLM_OK: s="CURLM_OK"; break;
114
112
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
115
113
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
116
114
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
134
132
/* Check for completed transfers, and remove their easy handles */
135
static void check_run_count(GlobalInfo *g)
133
static void check_multi_info(GlobalInfo *g)
137
if (g->prev_running > g->still_running) {
145
fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running);
147
I am still uncertain whether it is safe to remove an easy handle
148
from inside the curl_multi_info_read loop, so here I will search
149
for completed transfers in the inner "while" loop, and then remove
150
them in the outer "do-while" loop...
154
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
155
if (msg->msg == CURLMSG_DONE) {
156
easy=msg->easy_handle;
157
res=msg->data.result;
162
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
163
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
164
fprintf(MSG_OUT, "DONE: %s => (%d) %s\n", eff_url, res, conn->error);
165
curl_multi_remove_handle(g->multi, easy);
167
curl_easy_cleanup(easy);
142
fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running);
143
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
144
if (msg->msg == CURLMSG_DONE) {
145
easy = msg->easy_handle;
146
res = msg->data.result;
147
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
148
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
149
fprintf(MSG_OUT, "DONE: %s => (%d) %s\n", eff_url, res, conn->error);
150
curl_multi_remove_handle(g->multi, easy);
152
curl_easy_cleanup(easy);
172
g->prev_running = g->still_running;
184
(kind&EV_READ?CURL_CSELECT_IN:0)|
185
(kind&EV_WRITE?CURL_CSELECT_OUT:0);
188
rc = curl_multi_socket_action(g->multi, fd, action, &g->still_running);
189
} while (rc == CURLM_CALL_MULTI_PERFORM);
167
(kind & EV_READ ? CURL_CSELECT_IN : 0) |
168
(kind & EV_WRITE ? CURL_CSELECT_OUT : 0);
170
rc = curl_multi_socket_action(g->multi, fd, action, &g->still_running);
191
171
mcode_or_die("event_cb: curl_multi_socket_action", rc);
194
174
if ( g->still_running <= 0 ) {
195
175
fprintf(MSG_OUT, "last transfer done, kill timeout\n");
196
176
if (evtimer_pending(&g->timer_event, NULL)) {
213
rc = curl_multi_socket_action(g->multi,
192
rc = curl_multi_socket_action(g->multi,
214
193
CURL_SOCKET_TIMEOUT, 0, &g->still_running);
215
} while (rc == CURLM_CALL_MULTI_PERFORM);
216
194
mcode_or_die("timer_cb: curl_multi_socket_action", rc);
340
318
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSDATA, conn);
342
320
"Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
343
rc =curl_multi_add_handle(g->multi, conn->easy);
321
rc = curl_multi_add_handle(g->multi, conn->easy);
344
322
mcode_or_die("new_conn: curl_multi_add_handle", rc);
346
324
/* note that the add_handle() will set a time-out to trigger very soon so