提交 9d3db317 编写于 作者: M maweiye

fix sem_close unmapping of still-referenced semaphore

Signed-off-by: Nmaweiye <maweiye@huawei.com>
上级 6ece17fe
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册