From b59963aa25765c1b1c7b700f4fc9c75356233d0a Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Thu, 12 Sep 2019 09:33:25 +0000 Subject: [PATCH] Update: Run type_get_interfacecb() in unlocked state (guarded by ref) so it can call igloo_ro_ref() --- src/ro.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ro.c b/src/ro.c index 376ca0a..7975c8c 100644 --- a/src/ro.c +++ b/src/ro.c @@ -387,8 +387,23 @@ igloo_ro_t igloo_ro_get_interface(igloo_ro_t self, const igloo_ro_type_t *type, igloo_thread_mutex_unlock(&(base->lock)); return igloo_RO_NULL; } + /* create a temp reference + * This is required so we can run type_get_interfacecb() in unlocked state. + */ + base->refc++; + igloo_thread_mutex_unlock(&(base->lock)); + if (base->type->type_get_interfacecb) ret = base->type->type_get_interfacecb(self, type, name, associated); + + igloo_thread_mutex_lock(&(base->lock)); + /* remove temp reference + * If refc == 0 the application has a bug. + * TODO: We must tell someone about it. + * Anyway, we can not just set refc = -1, that will just break things more. + */ + if (base->refc) + base->refc--; igloo_thread_mutex_unlock(&(base->lock)); return ret;