From 3b68465b67f91e1f59bacd91c9e852abc63d0d63 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sun, 15 Sep 2019 15:26:07 +0000 Subject: [PATCH] Fix: Fixed deadlock on igloo_ro_get_instance() --- src/ro.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ro.c b/src/ro.c index cfd407a..f791691 100644 --- a/src/ro.c +++ b/src/ro.c @@ -351,14 +351,17 @@ igloo_ro_t igloo_ro_get_instance(igloo_ro_t self) } else { ret = base->instance; } + igloo_thread_mutex_unlock(&(base->lock)); + /* We do this after unlock to avoid dead locks. + * This is valid as we have at least a weak ref to the target + */ if (!igloo_RO_IS_NULL(ret)) { if (igloo_ro_ref(ret) != igloo_ERROR_NONE) { igloo_thread_mutex_unlock(&(base->lock)); return igloo_RO_NULL; } } - igloo_thread_mutex_unlock(&(base->lock)); return ret; }