mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-15 01:46:43 +08:00
MUTEX(9): Allow destruction of self-owned mutexes
This commit is contained in:
parent
45d74f2030
commit
1c61fdb62c
@ -299,15 +299,23 @@ mtx_sysinit(void *arg)
|
|||||||
void
|
void
|
||||||
mtx_destroy(struct mtx *m)
|
mtx_destroy(struct mtx *m)
|
||||||
{
|
{
|
||||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
rtems_status_code sc;
|
||||||
|
|
||||||
sc = rtems_semaphore_delete(m->lock_object.lo_id);
|
do {
|
||||||
BSD_ASSERT_SC(sc);
|
sc = rtems_semaphore_delete(m->lock_object.lo_id);
|
||||||
|
if (sc == RTEMS_RESOURCE_IN_USE) {
|
||||||
|
BSD_ASSERT(mtx_owned(m));
|
||||||
|
|
||||||
|
mtx_unlock(m);
|
||||||
|
} else {
|
||||||
|
BSD_ASSERT_SC(sc);
|
||||||
|
}
|
||||||
|
} while (sc != RTEMS_SUCCESSFUL);
|
||||||
|
|
||||||
rtems_chain_extract(&m->lock_object.lo_node);
|
rtems_chain_extract(&m->lock_object.lo_node);
|
||||||
|
|
||||||
m->lock_object.lo_id = 0;
|
m->lock_object.lo_id = 0;
|
||||||
m->lock_object.lo_flags &= ~LO_INITIALIZED;
|
m->lock_object.lo_flags &= ~LO_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user