diff options
author | tjr <tjr@FreeBSD.org> | 2003-01-14 03:36:45 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2003-01-14 03:36:45 +0000 |
commit | fc5f7e9a8b018cb40d5d12f0d66a7c7c40ed4c6f (patch) | |
tree | bbe801ccc4ea42a434e065d939a16f64c7ede171 /lib/libc/gen/sem.c | |
parent | 184d2efa56bcdd3b15ab5399f257c1285c02588e (diff) | |
download | FreeBSD-src-fc5f7e9a8b018cb40d5d12f0d66a7c7c40ed4c6f.zip FreeBSD-src-fc5f7e9a8b018cb40d5d12f0d66a7c7c40ed4c6f.tar.gz |
Add the newly created semaphore to the named semaphore list in sem_open()
so that multiple opens of the same semaphore without an intervening
sem_close() return the same object, and so that sem_close() does not
segfault while trying to remove the item from the list.
Diffstat (limited to 'lib/libc/gen/sem.c')
-rw-r--r-- | lib/libc/gen/sem.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libc/gen/sem.c b/lib/libc/gen/sem.c index fbed62a..d1cf10e 100644 --- a/lib/libc/gen/sem.c +++ b/lib/libc/gen/sem.c @@ -206,8 +206,9 @@ sem_open(const char *name, int oflag, ...) *sem = sem_alloc(value, semid, 1); if ((*sem) == NULL) goto err; - _pthread_mutex_unlock(&named_sems_mtx); + LIST_INSERT_HEAD(&named_sems, *sem, entry); (*sem)->backpointer = sem; + _pthread_mutex_unlock(&named_sems_mtx); return (sem); err: _pthread_mutex_unlock(&named_sems_mtx); |