From c064a0f1cab732569d9f332202660767510f2990 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Thu, 12 Nov 2015 17:35:37 -0800 Subject: [PATCH] lock should be global --- ReactNative/RealmReact.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReactNative/RealmReact.mm b/ReactNative/RealmReact.mm index 6fcc3982..574c917e 100644 --- a/ReactNative/RealmReact.mm +++ b/ReactNative/RealmReact.mm @@ -54,10 +54,10 @@ JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor, bool cre @interface RealmReact () { GCDWebServer *_webServer; std::unique_ptr _rpcServer; - std::mutex _rpcMutex; } @end +static std::mutex s_rpcMutex; static __weak RealmReact *s_currentRealmModule = nil; #endif @@ -86,7 +86,7 @@ static __weak RealmReact *s_currentRealmModule = nil; #if DEBUG - (void)startRPC { - std::lock_guard lock(_rpcMutex); + std::lock_guard lock(s_rpcMutex); [GCDWebServer setLogLevel:3]; _webServer = [[GCDWebServer alloc] init]; @@ -104,7 +104,7 @@ static __weak RealmReact *s_currentRealmModule = nil; dispatch_sync(dispatch_get_main_queue(), ^{ RealmReact *self = weakSelf; if (self) { - std::lock_guard lock(_rpcMutex); + std::lock_guard lock(s_rpcMutex); if (_rpcServer) { realm_js::json args = realm_js::json::parse([[(GCDWebServerDataRequest *)request text] UTF8String]); std::string responseText = _rpcServer->perform_request(request.path.UTF8String, args).dump(); @@ -133,7 +133,7 @@ static __weak RealmReact *s_currentRealmModule = nil; } - (void)shutdownRPC { - std::lock_guard lock(_rpcMutex); + std::lock_guard lock(s_rpcMutex); [_webServer stop]; [_webServer removeAllHandlers]; _webServer = nil;