From 59edc647773e076258a9f85dfc2d9914b581af18 Mon Sep 17 00:00:00 2001 From: ThePedroo Date: Thu, 1 Feb 2024 02:35:57 -0300 Subject: [PATCH] fix: curl deprecated warning This commit fixes a deprecated warning due to the usage of "curl_multi_socket_all" in libcurl versions. --- core/io_poller.c | 12 ++++++++---- core/websockets.c | 8 +++++++- src/discord-rest_request.c | 8 +++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/io_poller.c b/core/io_poller.c index b24478182..ce8fbc994 100644 --- a/core/io_poller.c +++ b/core/io_poller.c @@ -140,10 +140,14 @@ io_poller_perform(struct io_poller *io) if (curlm->should_perform || (-1 != curlm->timeout && now >= curlm->timeout)) { curlm->should_perform = false; - int result = - curlm->cb - ? curlm->cb(io, curlm->multi, curlm->user_data) - : curl_multi_socket_all(curlm->multi, &curlm->running); + + int result; + if (curlm->cb) { + result = curlm->cb(io, curlm->multi, curlm->user_data); + } else { + result = curl_multi_socket_action(curlm->multi, CURL_SOCKET_TIMEOUT, 0, &curlm->running); + if (result == CURLM_OK) result = curl_multi_perform(curlm->multi, &curlm->running); + } if (result != 0) return result; } diff --git a/core/websockets.c b/core/websockets.c index 502d61f49..4a0bd3b22 100644 --- a/core/websockets.c +++ b/core/websockets.c @@ -834,10 +834,16 @@ ws_multi_socket_run(struct websockets *ws, uint64_t *tstamp) /** update WebSockets concept of "now" */ *tstamp = ws_timestamp_update(ws); - mcode = curl_multi_socket_all(ws->mhandle, &is_running); + mcode = curl_multi_socket_action(ws->mhandle, CURL_SOCKET_TIMEOUT, 0, &is_running); if (mcode != CURLM_OK) CURLM_LOG(ws, mcode); + if (CURLM_OK != curl_multi_perform(ws->mhandle, &is_running)) { + logconf_error(&ws->conf, "curl_multi_perform() failed"); + + return false; + } + return is_running != 0; } diff --git a/src/discord-rest_request.c b/src/discord-rest_request.c index 488501364..cad89f67e 100644 --- a/src/discord-rest_request.c +++ b/src/discord-rest_request.c @@ -360,7 +360,7 @@ discord_requestor_info_read(struct discord_requestor *rqtor) { int alive = 0; - if (CURLM_OK != curl_multi_socket_all(rqtor->mhandle, &alive)) + if (CURLM_OK != curl_multi_socket_action(rqtor->mhandle, CURL_SOCKET_TIMEOUT, 0, &alive)) return CCORD_CURLM_INTERNAL; /* ask for any messages/informationals from the individual transfers */ @@ -445,6 +445,12 @@ discord_requestor_info_read(struct discord_requestor *rqtor) } } + int still_running = 0; + + /* Check if there are still running transfers */ + if (CURLM_OK != curl_multi_perform(rqtor->mhandle, &still_running)) + return CCORD_CURLM_INTERNAL; + return CCORD_OK; }