aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorManfred Spraul <manfred@colorfullife.com>2011-11-02 16:38:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-11-02 19:07:01 -0400
commit0b0577f6080c0645b079dcc03fdbaf40d928beb8 (patch)
tree0dcedf3f2e6c3aa9c363a4c6272225ebfa1c61c5 /ipc
parent3c24783bb2deafaa106b7e69a97540071afc590c (diff)
ipc/sem.c: handle spurious wakeups
semtimedop() does not handle spurious wakeups, it returns -EINTR to user space. Most other schedule() users would just loop and not return to user space. The patch adds such a loop to semtimedop() Signed-off-by: Manfred Spraul <manfred@colorfullife.com> Reported-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Mike Galbraith <efault@gmx.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/sem.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ipc/sem.c b/ipc/sem.c
index fb13be17945b..227948f28ce6 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1426,6 +1426,8 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
1426 1426
1427 queue.status = -EINTR; 1427 queue.status = -EINTR;
1428 queue.sleeper = current; 1428 queue.sleeper = current;
1429
1430sleep_again:
1429 current->state = TASK_INTERRUPTIBLE; 1431 current->state = TASK_INTERRUPTIBLE;
1430 sem_unlock(sma); 1432 sem_unlock(sma);
1431 1433
@@ -1478,6 +1480,13 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
1478 */ 1480 */
1479 if (timeout && jiffies_left == 0) 1481 if (timeout && jiffies_left == 0)
1480 error = -EAGAIN; 1482 error = -EAGAIN;
1483
1484 /*
1485 * If the wakeup was spurious, just retry
1486 */
1487 if (error == -EINTR && !signal_pending(current))
1488 goto sleep_again;
1489
1481 unlink_queue(sma, &queue); 1490 unlink_queue(sma, &queue);
1482 1491
1483out_unlock_free: 1492out_unlock_free: