aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2015-11-10 09:42:46 +0100
committerMartin Willi <martin@strongswan.org>2015-12-04 08:01:15 +0100
commit8b0c9cf155eb3505a643a3e769248a09fdf637f5 (patch)
treebf7830b2a3528b32df9ca647c44e07680ef35421 /src/libstrongswan
parentfc235f90fe0abcde3a5d1451b67ee6088939eb02 (diff)
downloadstrongswan-8b0c9cf155eb3505a643a3e769248a09fdf637f5.tar.bz2
strongswan-8b0c9cf155eb3505a643a3e769248a09fdf637f5.tar.xz
watcher: Check for cancellation if poll() fails with EINTR
With LinuxThreads, poll() is unfortunately no cancellation point. It seems that poll gets woken up after cancellation, but we actively must check for cancellation before re-entering poll to properly shut down the watcher thread.
Diffstat (limited to 'src/libstrongswan')
-rw-r--r--src/libstrongswan/processing/watcher.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstrongswan/processing/watcher.c b/src/libstrongswan/processing/watcher.c
index 5b94208bf..b7628501a 100644
--- a/src/libstrongswan/processing/watcher.c
+++ b/src/libstrongswan/processing/watcher.c
@@ -345,6 +345,13 @@ static job_requeue_t watch(private_watcher_t *this)
old = thread_cancelability(TRUE);
res = poll(pfd, count, -1);
+ if (res == -1 && errno == EINTR)
+ {
+ /* LinuxThreads interrupts poll(), but does not make it a
+ * cancellation point. Manually test if we got cancelled. */
+ thread_cancellation_point();
+ }
+
thread_cancelability(old);
thread_cleanup_pop(FALSE);