Skip to content

Commit

Permalink
BUG/MINOR: deferred calling the libev socket timer callback function
Browse files Browse the repository at this point in the history
On Linux systems with a newer cURL library (say ubuntu 22 which uses cURL
v7.81.0), the program crashes in the mir_curl_timer_cb() function (when
calling function mir_curl_ev_timer_cb()).

It was solved so that the call of the respective function is done via the
timer (and not directly as before).

This should fix GitHub issue #31.

Version of the program changed to v1.2.16.
  • Loading branch information
zaga00 committed Sep 14, 2022
1 parent a2dd6e4 commit 8037ac8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
1.2.15
1.2.16
2 changes: 1 addition & 1 deletion src/.build-counter
@@ -1 +1 @@
2495
2510
16 changes: 12 additions & 4 deletions src/curl.c
Expand Up @@ -444,13 +444,21 @@ static int mir_curl_timer_cb(CURLM *multi __maybe_unused, long timeout_ms, void

ev_timer_stop(curl->ev_base, &(curl->ev_timer));

if (timeout_ms > 0) {
/***
* If the value of argument timeout_ms is less than 0, then the timer
* should only be stopped; otherwise a timeout is set.
*/
if (timeout_ms >= 0) {
/***
* If timeout is set to 0, we will delay calling the callback
* function mir_curl_ev_timer_cb() by 1 millisecond.
*/
if (timeout_ms == 0)
timeout_ms = 1;

ev_timer_init(&(curl->ev_timer), mir_curl_ev_timer_cb, timeout_ms / 1000.0, 0.0);
ev_timer_start(curl->ev_base, &(curl->ev_timer));
}
else if (timeout_ms == 0) {
(void)mir_curl_ev_timer_cb(curl->ev_base, &(curl->ev_timer), 0);
}

ev_async_send(curl->ev_base, curl->ev_async);

Expand Down

0 comments on commit 8037ac8

Please sign in to comment.