summaryrefslogtreecommitdiffstats
path: root/rtemsbsd/rtems/rtems-bsd-mutex.c
diff options
context:
space:
mode:
Diffstat (limited to 'rtemsbsd/rtems/rtems-bsd-mutex.c')
-rw-r--r--rtemsbsd/rtems/rtems-bsd-mutex.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/rtemsbsd/rtems/rtems-bsd-mutex.c b/rtemsbsd/rtems/rtems-bsd-mutex.c
index f5901bd4..02960f9a 100644
--- a/rtemsbsd/rtems/rtems-bsd-mutex.c
+++ b/rtemsbsd/rtems/rtems-bsd-mutex.c
@@ -299,15 +299,23 @@ mtx_sysinit(void *arg)
void
mtx_destroy(struct mtx *m)
{
- rtems_status_code sc = RTEMS_SUCCESSFUL;
+ rtems_status_code sc;
- sc = rtems_semaphore_delete(m->lock_object.lo_id);
- BSD_ASSERT_SC(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);
- m->lock_object.lo_id = 0;
- m->lock_object.lo_flags &= ~LO_INITIALIZED;
+ m->lock_object.lo_id = 0;
+ m->lock_object.lo_flags &= ~LO_INITIALIZED;
}
void