Skip to content

Commit

Permalink
fix: curl deprecated warning
Browse files Browse the repository at this point in the history
This commit fixes a deprecated warning due to the usage of "curl_multi_socket_all" in libcurl versions.
  • Loading branch information
ThePedroo authored and lcsmuller committed Mar 21, 2024
1 parent 25aceab commit 59edc64
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
12 changes: 8 additions & 4 deletions core/io_poller.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 7 additions & 1 deletion core/websockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 7 additions & 1 deletion src/discord-rest_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 59edc64

Please sign in to comment.