1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

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.
This commit is contained in:
Tim J. Robbins 2003-01-14 03:36:45 +00:00
parent 264f5acaf6
commit a91b25dc1c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=109219
2 changed files with 4 additions and 2 deletions

View File

@ -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);

View File

@ -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);