From: Viktor Szakats Date: Wed, 26 Nov 2025 11:56:44 +0000 (+0100) Subject: examples/multi-uv: simplify passing `uv` struct X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b09ad8ecbb1e80bc5f621fc012080ab2abf61c4;p=thirdparty%2Fcurl.git examples/multi-uv: simplify passing `uv` struct Reported-by: st751228051 on github Follow-up to c722346518365c401b572f8dbe5fa6792ba923cd #19538 #19462 Closes #19707 --- diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c index 75fec20199..1dac320489 100644 --- a/docs/examples/multi-uv.c +++ b/docs/examples/multi-uv.c @@ -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 */