mirror of
https://github.com/curl/curl.git
synced 2026-07-15 20:17:20 +03:00
examples/multi-uv: simplify passing uv struct
Reported-by: st751228051 on github
Follow-up to c722346518 #19538 #19462
Closes #19707
This commit is contained in:
parent
c722346518
commit
0b09ad8ecb
1 changed files with 6 additions and 11 deletions
|
|
@ -104,7 +104,7 @@ static void add_download(const char *url, int num, CURLM *multi)
|
|||
fprintf(stderr, "Added download %s -> %s\n", url, filename);
|
||||
}
|
||||
|
||||
static void check_multi_info(struct curl_context *context)
|
||||
static void check_multi_info(struct datauv *uv)
|
||||
{
|
||||
char *done_url;
|
||||
CURLMsg *message;
|
||||
|
|
@ -112,7 +112,7 @@ static void check_multi_info(struct curl_context *context)
|
|||
CURL *curl;
|
||||
FILE *file;
|
||||
|
||||
while((message = curl_multi_info_read(context->uv->multi, &pending))) {
|
||||
while((message = curl_multi_info_read(uv->multi, &pending))) {
|
||||
switch(message->msg) {
|
||||
case CURLMSG_DONE:
|
||||
/* Do not use message data after calling curl_multi_remove_handle() and
|
||||
|
|
@ -126,7 +126,7 @@ static void check_multi_info(struct curl_context *context)
|
|||
curl_easy_getinfo(curl, CURLINFO_PRIVATE, &file);
|
||||
printf("%s DONE\n", done_url);
|
||||
|
||||
curl_multi_remove_handle(context->uv->multi, curl);
|
||||
curl_multi_remove_handle(uv->multi, curl);
|
||||
curl_easy_cleanup(curl);
|
||||
if(file) {
|
||||
fclose(file);
|
||||
|
|
@ -154,7 +154,7 @@ static void on_uv_socket(uv_poll_t *req, int status, int events)
|
|||
|
||||
curl_multi_socket_action(context->uv->multi, context->sockfd, flags,
|
||||
&running_handles);
|
||||
check_multi_info(context);
|
||||
check_multi_info(context->uv);
|
||||
}
|
||||
|
||||
/* callback from libuv when timeout expires */
|
||||
|
|
@ -167,13 +167,8 @@ static void on_uv_timeout(uv_timer_t *req)
|
|||
curl_multi_socket_action(uv->multi, CURL_SOCKET_TIMEOUT, 0,
|
||||
&running_handles);
|
||||
|
||||
/* We do not have a curl_context here, so we need to check messages
|
||||
differently. Create a temporary context just for the check. */
|
||||
if(running_handles) {
|
||||
struct curl_context temp_context;
|
||||
temp_context.uv = uv;
|
||||
check_multi_info(&temp_context);
|
||||
}
|
||||
if(running_handles)
|
||||
check_multi_info(uv);
|
||||
}
|
||||
|
||||
/* callback from libcurl to update the timeout expiry */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue