summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSami Kerola2015-02-10 00:18:09 +0100
committerKarel Zak2015-03-05 10:31:01 +0100
commit378543e13f93c522b976efddd1610a19a6601b1c (patch)
tree38467867c9467eb6cc23b91516be9364ef74bb7c /include
parentflock: add --verbose option (diff)
downloadkernel-qcow2-util-linux-378543e13f93c522b976efddd1610a19a6601b1c.tar.gz
kernel-qcow2-util-linux-378543e13f93c522b976efddd1610a19a6601b1c.tar.xz
kernel-qcow2-util-linux-378543e13f93c522b976efddd1610a19a6601b1c.zip
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 <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'include')
-rw-r--r--include/Makemodule.am1
-rw-r--r--include/monotonic.h4
-rw-r--r--include/timer.h31
3 files changed, 4 insertions, 32 deletions
diff --git a/include/Makemodule.am b/include/Makemodule.am
index c4a52e4cf..8d7c881d5 100644
--- a/include/Makemodule.am
+++ b/include/Makemodule.am
@@ -44,7 +44,6 @@ dist_noinst_HEADERS += \
include/swapprober.h \
include/swapheader.h \
include/sysfs.h \
- include/timer.h \
include/timeutils.h \
include/ttyutils.h \
include/widechar.h \
diff --git a/include/monotonic.h b/include/monotonic.h
index f3b03d3d0..d5ff7c8e5 100644
--- a/include/monotonic.h
+++ b/include/monotonic.h
@@ -8,4 +8,8 @@ extern int get_boot_time(struct timeval *boot_time);
extern int gettime_monotonic(struct timeval *tv);
+extern int setup_timer(timer_t * t_id, struct itimerval *timeout,
+ void (*timeout_handler)(void));
+extern void cancel_timer(timer_t * t_id);
+
#endif /* UTIL_LINUX_BOOTTIME_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 <signal.h>
-#include <sys/time.h>
-
-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