Skip to content

Commit

Permalink
Merge pull request #32 from Anotra/fix_timer
Browse files Browse the repository at this point in the history
Fix io_poller timer
  • Loading branch information
lcsmuller authored Feb 21, 2022
2 parents 604116a + fa9148d commit 0319e73
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions core/io_poller.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ io_poller_perform(struct io_poller *io)
}
for (int i = 0; i < io->curlm_cnt; i++) {
struct io_curlm *curlm = io->curlm[i];
if (curlm->should_perform || now >= curlm->timeout) {
if (curlm->should_perform ||
(-1 != curlm->timeout && now >= curlm->timeout)) {
curlm->should_perform = false;
int result = curlm->cb ?
curlm->cb(curlm->multi, curlm->user_data) :
Expand Down Expand Up @@ -312,4 +313,4 @@ io_poller_curlm_enable_perform(struct io_poller *io, CURLM *multi)
if (io->curlm[i]->multi == multi)
return (io->curlm[i]->should_perform = true);
return false;
}
}
3 changes: 3 additions & 0 deletions src/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ _discord_adapter_send(struct discord_adapter *adapter,
/* initiate libcurl transfer */
mcode = curl_multi_add_handle(adapter->mhandle, ehandle);

io_poller_curlm_enable_perform(CLIENT(adapter, adapter)->io_poller,
adapter->mhandle);

QUEUE_INSERT_TAIL(&cxt->bucket->busyq, &cxt->entry);

return mcode ? CCORD_CURLM_INTERNAL : CCORD_OK;
Expand Down
3 changes: 2 additions & 1 deletion src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ discord_run(struct discord *client)
if (next_gateway_run <= now) {
if (CCORD_OK != (code = discord_gateway_perform(&client->gw)))
break;

if (CCORD_OK != (code = discord_adapter_perform(&client->adapter)))
break;
next_gateway_run = now + 1000;
}
}
Expand Down

0 comments on commit 0319e73

Please sign in to comment.