From 09c9aad32d50581d2311179ba66236807e3b712e Mon Sep 17 00:00:00 2001 From: John Knox Date: Mon, 9 Jul 2018 07:46:01 -0700 Subject: [PATCH] iOS: Use separate thread for network connection Summary: We currently give sonar one event base from java / obj-c code to use for scheduling tasks. This causes a problem, because we schedule reconnect tasks on the event base, and then these tasks interact with rsocket which schedules it's own tasks. The problem is that we're passing rsocket the same event base. So the reconnect code executes and blocks waiting for rsocket to connect. But rsocket can never connect because it never executes because that thread is blocked, so we get deadlock. Fixing it by giving both processes their own event base / thread. Reviewed By: danielbuechele Differential Revision: D8748355 fbshipit-source-id: b0ad2172087f0103180677438f427c831db7f42c --- iOS/SonarKit/SonarClient.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iOS/SonarKit/SonarClient.mm b/iOS/SonarKit/SonarClient.mm index b534c8c10..b94d858cd 100644 --- a/iOS/SonarKit/SonarClient.mm +++ b/iOS/SonarKit/SonarClient.mm @@ -23,6 +23,7 @@ using WrapperPlugin = facebook::sonar::SonarCppWrapperPlugin; @implementation SonarClient { facebook::sonar::SonarClient *_cppClient; folly::ScopedEventBaseThread sonarThread; + folly::ScopedEventBaseThread connectionThread; #if !TARGET_OS_SIMULATOR // SKPortForwardingServer *_server; #endif @@ -70,7 +71,7 @@ using WrapperPlugin = facebook::sonar::SonarCppWrapperPlugin; [privateAppDirectory UTF8String], }, sonarThread.getEventBase(), - sonarThread.getEventBase() + connectionThread.getEventBase() }); _cppClient = facebook::sonar::SonarClient::instance(); }