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
This commit is contained in:
John Knox
2018-06-21 13:08:47 -07:00
committed by Facebook Github Bot
parent f520486c2d
commit 992c032fe7

View File

@@ -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(); });
}