MUTEX(9): Allow destruction of self-owned mutexes

This commit is contained in:
Sebastian Huber 2013-10-31 09:35:25 +01:00
parent 45d74f2030
commit 1c61fdb62c

View File

@ -299,10 +299,18 @@ mtx_sysinit(void *arg)
void
mtx_destroy(struct mtx *m)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
rtems_status_code sc;
do {
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);