diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2011-01-11 11:33:33 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-01-11 12:48:52 (GMT) |
commit | 76a0c085c8fc6e5f2a46b186a4a1c83e3713bd76 (patch) | |
tree | cd0b52553dfa158dea815d9ed8841c053e0a3b57 /src/corelib | |
parent | 54db2506e8f228487c109ec7efc7a2a9681e9087 (diff) | |
download | Qt-76a0c085c8fc6e5f2a46b186a4a1c83e3713bd76.zip Qt-76a0c085c8fc6e5f2a46b186a4a1c83e3713bd76.tar.gz Qt-76a0c085c8fc6e5f2a46b186a4a1c83e3713bd76.tar.bz2 |
make the modifySemaphore() signal-safe on linux
as POSIX man says, if semop() is interrupted by a signal,
it shall return -1 and set errno to EINTR.
in qcore_unix_p.h, we have EINTR_LOOP helper macro exactly for such cases ;)
Task-number: QTBUG-14434
Merge-request: 998
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qsystemsemaphore_unix.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp index 07e3618..9d0c0b9 100644 --- a/src/corelib/kernel/qsystemsemaphore_unix.cpp +++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp @@ -56,6 +56,8 @@ #include <sys/sem.h> +#include "private/qcore_unix_p.h" + // OpenBSD 4.2 doesn't define EIDRM, see BUGS section: // http://www.openbsd.org/cgi-bin/man.cgi?query=semop&manpath=OpenBSD+4.2 #if defined(Q_OS_OPENBSD) && !defined(EIDRM) @@ -218,7 +220,10 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count) operation.sem_num = 0; operation.sem_op = count; operation.sem_flg = SEM_UNDO; - if (-1 == semop(semaphore, &operation, 1)) { + + register int res; + EINTR_LOOP(res, semop(semaphore, &operation, 1)); + if (-1 == res) { // If the semaphore was removed be nice and create it and then modifySemaphore again if (errno == EINVAL || errno == EIDRM) { semaphore = -1; |