Add TFO support to AsyncSSLSocket
authorSubodh Iyengar <subodh@fb.com>
Tue, 7 Jun 2016 14:43:37 +0000 (07:43 -0700)
committerFacebook Github Bot 7 <facebook-github-bot-7-bot@fb.com>
Tue, 7 Jun 2016 14:53:33 +0000 (07:53 -0700)
commit889fe563fac92a64fd1a850bb09e9f6b7c431ac2
treebd531cee1bf31582711deb5c79393da8d8e61a71
parent0c620c8f910f407314ff19f4b44c770fe938fe36
Add TFO support to AsyncSSLSocket

Summary:
This adds TFO support to AsyncSSLSocket which
uses the support for TFO from AsyncSocket.

Because of the way AsyncSSLSocket inherits from
AsyncSocket it is tricky.

The following changes were made:
1. Openssl internally will treat only errors with return
code -1 as READ_REQUIRED or WRITE_REQUIRED errors. So this
diff changes the return value of the errors in the TFO fallback
cases to -1.

2. In case we fallback after SSL_connect() to a normal connect,
we would have to restart the connection process after connect
succeeds. To do this this overrides the connection success callback
and restarts the connection before sending the callback to AsyncSocket
because sometimes callbacks might synchronously call sslConn() in the
normal connect cases.

3. Delegated bioWrite to call sendSocketMessage instead of sendmsg directly.

Reviewed By: djwatson

Differential Revision: D3391735

fbshipit-source-id: 61434f6de4a9c3d03973c9ab9e51eb49e751e5cf
folly/io/async/AsyncSSLSocket.cpp
folly/io/async/AsyncSSLSocket.h
folly/io/async/AsyncSocket.cpp
folly/io/async/AsyncSocket.h
folly/io/async/test/AsyncSSLSocketTest.cpp
folly/io/async/test/AsyncSSLSocketTest.h
folly/io/async/test/BlockingSocket.h
folly/io/async/test/SocketClient.cpp