lxip: fix timer deletion and modification

Linux del_timer() and mod_timer() return if the timer was pending before
the modification. Additionally, these functions are potentially called
from handler function of the timer to modify and, therefore, checking
for timeout != INVALID_TIMEOUT is not sufficient as the timeout is
indeed valid when the handler is executed.
This commit is contained in:
Christian Helmuth 2017-09-20 22:29:40 +02:00
parent 9ff82d76c0
commit 7b9edcf90c
1 changed files with 2 additions and 2 deletions

View File

@ -230,7 +230,7 @@ class Lx::Timer
if (!ctx)
return 0;
int rv = ctx->timeout != Context::INVALID_TIMEOUT ? 1 : 0;
int rv = ctx->pending ? 1 : 0;
_list.remove(ctx);
destroy(&_timer_alloc, ctx);
@ -253,7 +253,7 @@ class Lx::Timer
* If timer was already active return 1, otherwise 0. The return
* value is needed by mod_timer().
*/
int rv = ctx->timeout != Context::INVALID_TIMEOUT ? 1 : 0;
int rv = ctx->pending ? 1 : 0;
_schedule_timer(ctx, expires);