*fix* make timer non-blocking to fix freezing when a timer is resetted in a callback function

git-svn-id: http://tint2.googlecode.com/svn/trunk@282 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
Andreas.Fink85
2009-11-30 15:36:06 +00:00
parent cb9f2f7517
commit 6c40536d1a
2 changed files with 19 additions and 16 deletions

View 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;
}