Fix detaching from evb
authorSubodh Iyengar <subodh@fb.com>
Tue, 20 Sep 2016 23:25:32 +0000 (16:25 -0700)
committerFacebook Github Bot 4 <facebook-github-bot-4-bot@fb.com>
Tue, 20 Sep 2016 23:38:35 +0000 (16:38 -0700)
Summary:
When we attach and detach from the
event base threads during connections
in the case of SSL it could result in
a crash while using TFO.

When TFO was enabled connectTimeout_
was set, which was not detached.

In the case when we would
fall back from TFO in case TFO did not
succeed, we would try and schedule a
connect timeout again. However because
we are now scheduled in a new evb thread,
this would cause the scheduleTimeout to
assert that it was not in the correct evb
thread.

This fixes the issue by attaching and detaching
connect timeouts as well.

Reviewed By: ngoyal

Differential Revision: D3892490

fbshipit-source-id: 278c0b8029022144cd59366ceb0ce83f0a60a307

folly/io/async/AsyncSSLSocket.h

index 2e09935c0de5f5048989b8cfe06df6b3ba92b85d..45fbaea4a97d5f391da1ee23c466a90309153cae 100644 (file)
@@ -479,11 +479,13 @@ class AsyncSSLSocket : public virtual AsyncSocket {
   virtual void attachEventBase(EventBase* eventBase) override {
     AsyncSocket::attachEventBase(eventBase);
     handshakeTimeout_.attachEventBase(eventBase);
+    connectionTimeout_.attachEventBase(eventBase);
   }
 
   virtual void detachEventBase() override {
     AsyncSocket::detachEventBase();
     handshakeTimeout_.detachEventBase();
+    connectionTimeout_.detachEventBase();
   }
 
   virtual bool isDetachable() const override {