]> Dogcows Code - chaz/tint2/blobdiff - src/util/timer.c
*fix* make timer non-blocking to fix freezing when a timer is resetted in a callback...
[chaz/tint2] / src / util / timer.c
index e218877946dec17bdf0263b47257d8368227b659..48529dc3f22b8731aadfb70b86c9efe8311930c6 100644 (file)
@@ -18,6 +18,7 @@
 #include <sys/timerfd.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 #include "timer.h"
 
@@ -38,6 +39,11 @@ int install_timer(int value_sec, int value_nsec, int interval_sec, int interval_
        t->id=timer_fd;
        t->_callback = _callback;
        timer_list = g_slist_prepend(timer_list, t);
+
+       int flags = fcntl( timer_fd, F_GETFL, 0 );
+       if( flags != -1 )
+               fcntl( timer_fd, F_SETFL, flags | O_NONBLOCK );
+
        return timer_fd;
 }
 
This page took 0.020642 seconds and 4 git commands to generate.