aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorManfred Spraul <manfred@colorfullife.com>2014-06-06 17:37:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-06 19:08:15 -0400
commit1994862dc9c16f360a9169a4d27200d15ba29713 (patch)
tree32bce71a3486a217a3b87b86ac55f9b69e75eff6 /ipc
parent4bb6657dd3a55ab507502d82dbee9db276602669 (diff)
ipc/sem.c: bugfix for semctl(,,GETZCNT)
GETZCNT is supposed to return the number of threads that wait until a semaphore value becomes 0. The current implementation overlooks complex operations that contain both wait-for-zero operation and operations that alter at least one semaphore. The patch fixes that. It's intentionally copy&paste, this will be cleaned up in the next patch. Signed-off-by: Manfred Spraul <manfred@colorfullife.com> Cc: Davidlohr Bueso <davidlohr.bueso@hp.com> Cc: Michael Kerrisk <mtk.manpages@gmail.com> 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.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ipc/sem.c b/ipc/sem.c
index fe0928a3d08b..4321fa420fe1 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1047,6 +1047,16 @@ static int count_semzcnt(struct sem_array *sma, ushort semnum)
1047 && !(sops[i].sem_flg & IPC_NOWAIT)) 1047 && !(sops[i].sem_flg & IPC_NOWAIT))
1048 semzcnt++; 1048 semzcnt++;
1049 } 1049 }
1050 list_for_each_entry(q, &sma->pending_alter, list) {
1051 struct sembuf *sops = q->sops;
1052 int nsops = q->nsops;
1053 int i;
1054 for (i = 0; i < nsops; i++)
1055 if (sops[i].sem_num == semnum
1056 && (sops[i].sem_op == 0)
1057 && !(sops[i].sem_flg & IPC_NOWAIT))
1058 semzcnt++;
1059 }
1050 return semzcnt; 1060 return semzcnt;
1051} 1061}
1052 1062