Stop using delayedUnsafe

Summary:
Having another attempt at removing this. It's unsafe because it in some cases executes the .then() task in the timekeeper thread, rather than the executor the original future is using.
When that default executor is an InlineExecutor, for example, you can get stack overflow.

I tried to remove this use before, but having the same thread used for both the sonar client itself and rsocket, meant that they entered a deadlock trying to connect.
Now that I've separated those jobs into separate threads, they can execute independently.

Reviewed By: danielbuechele

Differential Revision: D8748356

fbshipit-source-id: a1029ece2c7006ad7642cbf8aa59e692c76b19b2
This commit is contained in:
John Knox
2018-07-09 07:46:06 -07:00
committed by Facebook Github Bot
parent 26d58557ee
commit 85e6bf6d51

View File

@@ -99,7 +99,7 @@ SonarWebSocketImpl::~SonarWebSocketImpl() {
void SonarWebSocketImpl::start() { void SonarWebSocketImpl::start() {
folly::makeFuture() folly::makeFuture()
.via(sonarEventBase_->getEventBase()) .via(sonarEventBase_->getEventBase())
.delayedUnsafe(std::chrono::milliseconds(0)) .delayed(std::chrono::milliseconds(0))
.then([this]() { startSync(); }); .then([this]() { startSync(); });
} }
@@ -185,7 +185,7 @@ void SonarWebSocketImpl::connectSecurely() {
void SonarWebSocketImpl::reconnect() { void SonarWebSocketImpl::reconnect() {
folly::makeFuture() folly::makeFuture()
.via(sonarEventBase_->getEventBase()) .via(sonarEventBase_->getEventBase())
.delayedUnsafe(std::chrono::seconds(reconnectIntervalSeconds)) .delayed(std::chrono::seconds(reconnectIntervalSeconds))
.then([this]() { startSync(); }); .then([this]() { startSync(); });
} }