From 378543e13f93c522b976efddd1610a19a6601b1c Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 9 Feb 2015 23:18:09 +0000 Subject: flock: improve timeout handling Signal ALRM raised by the timer, and the timer only, will be considered as a timeout criteria. Secondly time interval is made to use monotonic clock. Documentation of ITIMER_REAL is unclear whether that time is affected various sources of clock skew, or does it even tick when system is suspended. Reviewed-by: Karel Zak Signed-off-by: Sami Kerola --- include/timer.h | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 include/timer.h (limited to 'include/timer.h') diff --git a/include/timer.h b/include/timer.h deleted file mode 100644 index 79ef64919..000000000 --- a/include/timer.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef UTIL_LINUX_TIMER_H -#define UTIL_LINUX_TIMER_H - -#include -#include - -static inline int setup_timer( - struct itimerval *timer, - struct itimerval *old_timer, - struct sigaction *old_sa, - void (*timeout_handler)(int)) -{ - struct sigaction sa; - - memset(&sa, 0, sizeof sa); - sa.sa_handler = timeout_handler; - sa.sa_flags = SA_RESETHAND; - sigaction(SIGALRM, &sa, old_sa); - - return setitimer(ITIMER_REAL, timer, old_timer); -} - -static inline void cancel_timer( - struct itimerval *old_timer, - struct sigaction *old_sa) -{ - setitimer(ITIMER_REAL, old_timer, NULL); - sigaction(SIGALRM, old_sa, NULL); -} - -#endif -- cgit v1.2.3-55-g7522