From 992c032fe77ee6a7bad16fd273c7b52e5472ac7d Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 21 Jun 2018 13:08:47 -0700 Subject: [PATCH] Fix infinite recursion issue when can't connect Summary: There's an issue with folly's delayedUnsafe(), where it drops your executor and effectively runs all futures inline, in this case instead of scheduling tasks for the future, it grows the stack indefinitely. This fixes the issue by using the safe delayed(), which preserves the executor, so the jobs get shceduled on a different thread as intended. Reviewed By: LeeHowes Differential Revision: D8575956 fbshipit-source-id: c5b2ced43a70505c51883281f202ac947ae6723f --- xplat/Sonar/SonarWebSocketImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xplat/Sonar/SonarWebSocketImpl.cpp b/xplat/Sonar/SonarWebSocketImpl.cpp index 24c68faa9..fe9f5d12f 100644 --- a/xplat/Sonar/SonarWebSocketImpl.cpp +++ b/xplat/Sonar/SonarWebSocketImpl.cpp @@ -99,7 +99,7 @@ SonarWebSocketImpl::~SonarWebSocketImpl() { void SonarWebSocketImpl::start() { folly::makeFuture() .via(worker_->getEventBase()) - .delayedUnsafe(std::chrono::milliseconds(0)) + .delayed(std::chrono::milliseconds(0)) .then([this]() { startSync(); }); } @@ -185,7 +185,7 @@ void SonarWebSocketImpl::connectSecurely() { void SonarWebSocketImpl::reconnect() { folly::makeFuture() .via(worker_->getEventBase()) - .delayedUnsafe(std::chrono::seconds(reconnectIntervalSeconds)) + .delayed(std::chrono::seconds(reconnectIntervalSeconds)) .then([this]() { startSync(); }); }