From 84fbf1da01badb1a563597f23358a8c8bf77bff6 Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Sat, 20 Apr 2013 22:30:00 +0200 Subject: [PATCH 4/4] ipc, sem: check if the ipc lock has been already taken Original patch from [1]. [ dileks: ChangeLog v1->v2: - Refreshed against next-20130419 plus 3 ipc-sem-next patches from [2] - Beautify comment and if-statement ] [1] http://marc.info/?t=136631457900005&r=1&w=2 [2] http://marc.info/?l=linux-next&m=136640233601913&w=2 --- ipc/sem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ipc/sem.c b/ipc/sem.c index acada9f..c1dfbfb 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -1259,10 +1259,11 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, err = -EIDRM; goto out_free; } - sem_unlock(sma, -1); } - sem_lock(sma, NULL, -1); + /* Has the ipc lock already been taken? */ + if (nsems <= SEMMSL_FAST) + sem_lock(sma, NULL, -1); for (i = 0; i < sma->sem_nsems; i++) sem_io[i] = sma->sem_base[i].semval; sem_unlock(sma, -1); -- 1.8.2.1