lkml.org 
[lkml]   [2014]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/6] ipc/sem.c: Bugfix for semctl(,,GETZCNT)
Date
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>
---
ipc/sem.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/ipc/sem.c b/ipc/sem.c
index 5749b9c..dc648f8 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1047,6 +1047,16 @@ static int count_semzcnt(struct sem_array *sma, ushort semnum)
&& !(sops[i].sem_flg & IPC_NOWAIT))
semzcnt++;
}
+ list_for_each_entry(q, &sma->pending_alter, list) {
+ struct sembuf *sops = q->sops;
+ int nsops = q->nsops;
+ int i;
+ for (i = 0; i < nsops; i++)
+ if (sops[i].sem_num == semnum
+ && (sops[i].sem_op == 0)
+ && !(sops[i].sem_flg & IPC_NOWAIT))
+ semzcnt++;
+ }
return semzcnt;
}

--
1.9.0


\
 
 \ /
  Last update: 2014-05-10 12:21    [W:0.126 / U:0.752 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site