Commit a93384bd authored by Woo Xie's avatar Woo Xie Committed by Sara Golemon

move the socket setting into setReadCB()

Summary: refactor D2201181

Reviewed By: @afrind

Differential Revision: D2202245
parent 4638bf34
......@@ -1070,20 +1070,27 @@ AsyncSSLSocket::handleConnect() noexcept {
AsyncSocket::handleInitialReadWrite();
}
void AsyncSSLSocket::prepareReadBuffer(void** buf, size_t* buflen) noexcept {
CHECK(readCallback_);
void AsyncSSLSocket::setReadCB(ReadCallback *callback) {
#ifdef SSL_MODE_MOVE_BUFFER_OWNERSHIP
// turn on the buffer movable in openssl
if (!isBufferMovable_ && readCallback_->isBufferMovable()) {
SSL_set_mode(ssl_, SSL_get_mode(ssl_) | SSL_MODE_MOVE_BUFFER_OWNERSHIP);
*buf = nullptr;
*buflen = 0;
isBufferMovable_ = true;
return;
}
#endif
// buf is necessary for SSLSocket without SSL_MODE_MOVE_BUFFER_OWNERSHIP
readCallback_->getReadBuffer(buf, buflen);
AsyncSocket::setReadCB(callback);
}
void AsyncSSLSocket::prepareReadBuffer(void** buf, size_t* buflen) noexcept {
CHECK(readCallback_);
if (isBufferMovable_) {
*buf = nullptr;
*buflen = 0;
} else {
// buf is necessary for SSLSocket without SSL_MODE_MOVE_BUFFER_OWNERSHIP
readCallback_->getReadBuffer(buf, buflen);
}
}
void
......
......@@ -673,6 +673,7 @@ class AsyncSSLSocket : public virtual AsyncSocket {
// Inherit event notification methods from AsyncSocket except
// the following.
void setReadCB(ReadCallback* callback) override;
void prepareReadBuffer(void** buf, size_t* buflen) noexcept override;
void handleRead() noexcept override;
void handleWrite() noexcept override;
......
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