From a52e25102f55ad72978c6a4691c3aeece7d18563 Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Sat, 6 Dec 2014 22:52:07 -0800 Subject: [PATCH] Fix locking bug in nn_global_submit_statistics() nn_global_submit_statistics() had a locking bug where a nn_glock_lock() does not always get nn_glock_unlocked(). This appears to fix issue #341 ("SUB fails after ~tens of seconds on OSX 10.10 (Yosemite)") in which socket communication fails after 10 seconds on OSX. nn_global_submit_statistics() is called every 10 seconds by default. Signed-off-by: bryan newbold --- src/core/global.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/global.c b/src/core/global.c index 672345dac..633ab2237 100644 --- a/src/core/global.c +++ b/src/core/global.c @@ -1124,10 +1124,14 @@ static void nn_global_submit_statistics () nn_glock_lock (); s = self.socks [i]; - if (!s) + if (!s) { + nn_glock_unlock (); continue; - if (i == self.statistics_socket) + } + if (i == self.statistics_socket) { + nn_glock_unlock (); continue; + } nn_ctx_enter (&s->ctx); nn_glock_unlock ();