115
111
/* Check for completed transfers, and remove their easy handles */
116
static void check_run_count(GlobalInfo *g)
112
static void check_multi_info(GlobalInfo *g)
118
if (g->prev_running > g->still_running) {
126
MSG_OUT("REMAINING: %d\n", g->still_running);
128
I am still uncertain whether it is safe to remove an easy handle
129
from inside the curl_multi_info_read loop, so here I will search
130
for completed transfers in the inner "while" loop, and then remove
131
them in the outer "do-while" loop...
135
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
136
if (msg->msg == CURLMSG_DONE) {
137
easy=msg->easy_handle;
138
res=msg->data.result;
143
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
144
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
145
MSG_OUT("DONE: %s => (%d) %s\n", eff_url, res, conn->error);
146
curl_multi_remove_handle(g->multi, easy);
148
curl_easy_cleanup(easy);
153
MSG_OUT("Requested: %d Completed:%d\n", g->requested, g->completed);
121
MSG_OUT("REMAINING: %d\n", g->still_running);
122
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
123
if (msg->msg == CURLMSG_DONE) {
124
easy = msg->easy_handle;
125
res = msg->data.result;
126
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
127
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
128
MSG_OUT("DONE: %s => (%d) %s\n", eff_url, res, conn->error);
129
curl_multi_remove_handle(g->multi, easy);
131
curl_easy_cleanup(easy);
155
g->prev_running = g->still_running;
161
139
/* Called by glib when our timeout expires */
162
140
static gboolean timer_cb(gpointer data)
164
142
GlobalInfo *g = (GlobalInfo *)data;
168
rc = curl_multi_socket(g->multi, CURL_SOCKET_TIMEOUT, &g->still_running);
169
} while (rc == CURLM_CALL_MULTI_PERFORM);
170
mcode_or_die("timer_cb: curl_multi_socket", rc);
145
rc = curl_multi_socket_action(g->multi,
146
CURL_SOCKET_TIMEOUT, 0, &g->still_running);
147
mcode_or_die("timer_cb: curl_multi_socket_action", rc);
198
175
GlobalInfo *g = (GlobalInfo*) data;
200
177
int fd=g_io_channel_unix_get_fd(ch);
202
rc = curl_multi_socket(g->multi, fd, &g->still_running);
203
} while (rc == CURLM_CALL_MULTI_PERFORM);
204
mcode_or_die("event_cb: curl_multi_socket", rc);
180
(condition & G_IO_IN ? CURL_CSELECT_IN : 0) |
181
(condition & G_IO_OUT ? CURL_CSELECT_OUT : 0);
183
rc = curl_multi_socket_action(g->multi, fd, action, &g->still_running);
184
mcode_or_die("event_cb: curl_multi_socket_action", rc);
206
187
if(g->still_running) {
338
319
MSG_OUT("Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
339
320
rc =curl_multi_add_handle(g->multi, conn->easy);
340
321
mcode_or_die("new_conn: curl_multi_add_handle", rc);
343
rc = curl_multi_socket_all(g->multi, &g->still_running);
344
} while (CURLM_CALL_MULTI_PERFORM == rc);
345
mcode_or_die("new_conn: curl_multi_socket_all", rc);
323
/* note that the add_handle() will set a time-out to trigger very soon so
324
that the necessary socket_action() call will be called by this app */
451
429
curl_multi_setopt(g->multi, CURLMOPT_SOCKETDATA, g);
452
430
curl_multi_setopt(g->multi, CURLMOPT_TIMERFUNCTION, update_timeout_cb);
453
431
curl_multi_setopt(g->multi, CURLMOPT_TIMERDATA, g);
455
rc = curl_multi_socket_all(g->multi, &g->still_running);
456
} while (CURLM_CALL_MULTI_PERFORM == rc);
433
/* we don't call any curl_multi_socket*() function yet as we have no handles
457
436
g_main_loop_run(gmain);
458
437
curl_multi_cleanup(g->multi);