mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-02 13:52:35 +07:00
Don't call uev_timer_set() when stopping timer, just close() it
The semantics for timerfd in Linux is to use close() to stop, so no need for the extra overhead with uev_timer_set(). Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -170,17 +170,12 @@ int uev_timer_start(uev_t *w)
|
||||
*/
|
||||
int uev_timer_stop(uev_t *w)
|
||||
{
|
||||
/* Check if already stopped in uev_run() after cb() or _init() */
|
||||
if (!_uev_watcher_active(w))
|
||||
return 0;
|
||||
|
||||
/* Stop kernel timer */
|
||||
uev_timer_set(w, 0, 0);
|
||||
|
||||
if (_uev_watcher_stop(w))
|
||||
return -1;
|
||||
|
||||
/* Close timerfd, will have to be reopened again on reset */
|
||||
close(w->fd);
|
||||
w->fd = -1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user