[Pdns-dev] [PATCH] Handle EINTR in Semaphore::wait()
Anders Kaseorg
andersk at ksplice.com
Mon Dec 13 21:19:09 CET 2010
Hi,
Can I get a developer to look at this patch to make Semaphore::wait()
handle EINTR?
Right now the callers of wait() ignore its return value, which leads to
crashes, for example, when sending SIGSTOP and SIGCONT to a running
pdns_server. The callers should also be updated to notice errors, but
this fixes the most common case, since EINTR can happen at any time during
normal operation.
I also submitted it to the Trac: http://wiki.powerdns.com/trac/ticket/326
Anders
diff -ur pdns-2.9.22.orig/pdns/unix_semaphore.cc pdns-2.9.22/pdns/unix_semaphore.cc
--- pdns-2.9.22.orig/pdns/unix_semaphore.cc 2008-11-15 15:32:46.000000000 -0500
+++ pdns-2.9.22/pdns/unix_semaphore.cc 2010-11-12 18:24:00.815081488 -0500
@@ -156,7 +156,11 @@
int Semaphore::wait()
{
- return sem_wait(m_pSemaphore);
+ int ret;
+ do
+ ret = sem_wait(m_pSemaphore);
+ while (ret == -1 && errno == EINTR);
+ return ret;
}
int Semaphore::tryWait()
{
More information about the Pdns-dev
mailing list