Commit f509d73d authored by Subodh Iyengar's avatar Subodh Iyengar Committed by Facebook Github Bot 9

Allow httpsession to be movable readCB

Summary:Allow HTTPSession to have a movable read
callback independent of the openssl check.

This allows other downstream transports to
deliver app data more efficiently.

Reviewed By: w-o-o, knekritz

Differential Revision: D3023517

fb-gh-sync-id: ff27c0e14f7364ad7d7b0028ef740b2678dbcb4c
shipit-source-id: ff27c0e14f7364ad7d7b0028ef740b2678dbcb4c
parent f4a80a41
...@@ -1172,7 +1172,7 @@ AsyncSSLSocket::handleConnect() noexcept { ...@@ -1172,7 +1172,7 @@ AsyncSSLSocket::handleConnect() noexcept {
void AsyncSSLSocket::setReadCB(ReadCallback *callback) { void AsyncSSLSocket::setReadCB(ReadCallback *callback) {
#ifdef SSL_MODE_MOVE_BUFFER_OWNERSHIP #ifdef SSL_MODE_MOVE_BUFFER_OWNERSHIP
// turn on the buffer movable in openssl // turn on the buffer movable in openssl
if (ssl_ != nullptr && !isBufferMovable_ && if (bufferMovableEnabled_ && ssl_ != nullptr && !isBufferMovable_ &&
callback != nullptr && callback->isBufferMovable()) { callback != nullptr && callback->isBufferMovable()) {
SSL_set_mode(ssl_, SSL_get_mode(ssl_) | SSL_MODE_MOVE_BUFFER_OWNERSHIP); SSL_set_mode(ssl_, SSL_get_mode(ssl_) | SSL_MODE_MOVE_BUFFER_OWNERSHIP);
isBufferMovable_ = true; isBufferMovable_ = true;
...@@ -1182,6 +1182,10 @@ void AsyncSSLSocket::setReadCB(ReadCallback *callback) { ...@@ -1182,6 +1182,10 @@ void AsyncSSLSocket::setReadCB(ReadCallback *callback) {
AsyncSocket::setReadCB(callback); AsyncSocket::setReadCB(callback);
} }
void AsyncSSLSocket::setBufferMovableEnabled(bool enabled) {
bufferMovableEnabled_ = enabled;
}
void AsyncSSLSocket::prepareReadBuffer(void** buf, size_t* buflen) noexcept { void AsyncSSLSocket::prepareReadBuffer(void** buf, size_t* buflen) noexcept {
CHECK(readCallback_); CHECK(readCallback_);
if (isBufferMovable_) { if (isBufferMovable_) {
......
...@@ -676,6 +676,13 @@ class AsyncSSLSocket : public virtual AsyncSocket { ...@@ -676,6 +676,13 @@ class AsyncSSLSocket : public virtual AsyncSocket {
void setReadCB(ReadCallback* callback) override; void setReadCB(ReadCallback* callback) override;
/**
* Tries to enable the buffer movable experimental feature in openssl.
* This is not guaranteed to succeed in case openssl does not have
* the experimental feature built in.
*/
void setBufferMovableEnabled(bool enabled);
/** /**
* Returns the peer certificate, or nullptr if no peer certificate received. * Returns the peer certificate, or nullptr if no peer certificate received.
*/ */
...@@ -828,6 +835,7 @@ class AsyncSSLSocket : public virtual AsyncSocket { ...@@ -828,6 +835,7 @@ class AsyncSSLSocket : public virtual AsyncSocket {
bool parseClientHello_{false}; bool parseClientHello_{false};
bool cacheAddrOnFailure_{false}; bool cacheAddrOnFailure_{false};
bool bufferMovableEnabled_{false};
std::unique_ptr<ssl::ClientHelloInfo> clientHelloInfo_; std::unique_ptr<ssl::ClientHelloInfo> clientHelloInfo_;
// Time taken to complete the ssl handshake. // Time taken to complete the ssl handshake.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment