summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/thread/sem_open.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/thread/sem_open.c b/src/thread/sem_open.c
index de8555c5..6fb0c5b2 100644
--- a/src/thread/sem_open.c
+++ b/src/thread/sem_open.c
@@ -163,10 +163,12 @@ int sem_close(sem_t *sem)
int i;
LOCK(lock);
for (i=0; i<SEM_NSEMS_MAX && semtab[i].sem != sem; i++);
- if (!--semtab[i].refcnt) {
- semtab[i].sem = 0;
- semtab[i].ino = 0;
+ if (--semtab[i].refcnt) {
+ UNLOCK(lock);
+ return 0;
}
+ semtab[i].sem = 0;
+ semtab[i].ino = 0;
UNLOCK(lock);
munmap(sem, sizeof *sem);
return 0;