From e36d8abcc9910986b1a5f9def5cce46f8407a12e Mon Sep 17 00:00:00 2001 From: Raoul Wols Date: Thu, 16 Sep 2021 11:44:00 +0200 Subject: [PATCH 1/2] Remove ev_timer_again calls The documentation says about this function: If the timer is started but non-repeating, stop it (as if it timed out). The timers are non-repeating, so we don't want this call. https://linux.die.net/man/3/ev --- include/amqpcpp/libev.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/amqpcpp/libev.h b/include/amqpcpp/libev.h index e2dfa2e..99b4a19 100644 --- a/include/amqpcpp/libev.h +++ b/include/amqpcpp/libev.h @@ -271,9 +271,6 @@ private: // reset the timer to trigger again later ev_timer_set(&_timer, std::min(_next, _expire) - now, 0.0); - // restart the timer - ev_timer_again(_loop, &_timer); - // and because the timer is running again, we restore the refcounter ev_unref(_loop); } @@ -368,9 +365,6 @@ private: // find the earliest thing that expires ev_timer_set(&_timer, std::min(_next, _expire) - now, 0.0); - // restart the timer - ev_timer_again(_loop, &_timer); - // expose the accepted interval return _timeout; } From 658da59a1b4397198ab371cbd25e52e8d383a57e Mon Sep 17 00:00:00 2001 From: Raoul Wols Date: Thu, 16 Sep 2021 12:31:23 +0200 Subject: [PATCH 2/2] Also start it again --- include/amqpcpp/libev.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/amqpcpp/libev.h b/include/amqpcpp/libev.h index 99b4a19..76eea2f 100644 --- a/include/amqpcpp/libev.h +++ b/include/amqpcpp/libev.h @@ -267,9 +267,12 @@ private: // sent only after _timout/2 seconds again _from now_ (no catching up) _next = now + std::max(_timeout / 2, 1); } - + // reset the timer to trigger again later ev_timer_set(&_timer, std::min(_next, _expire) - now, 0.0); + + // and start it again + ev_timer_start(_loop, &_timer); // and because the timer is running again, we restore the refcounter ev_unref(_loop);