From 3edc6278eab6f2b2ea79f75344c8a6711e80fa45 Mon Sep 17 00:00:00 2001 From: Yang Chi Date: Thu, 3 Mar 2016 19:47:53 -0800 Subject: [PATCH] Remove persistentCork in native land Summary: Remove persistent cork Reviewed By: francis-ma Differential Revision: D3008550 fb-gh-sync-id: a5ce492876d98d74f5669c5ec5ff3486c0cb0b2c shipit-source-id: a5ce492876d98d74f5669c5ec5ff3486c0cb0b2c --- folly/io/async/AsyncSSLSocket.cpp | 2 +- folly/io/async/AsyncSSLSocket.h | 2 ++ folly/io/async/AsyncSocket.cpp | 31 ------------------------------- folly/io/async/AsyncSocket.h | 21 --------------------- 4 files changed, 3 insertions(+), 53 deletions(-) diff --git a/folly/io/async/AsyncSSLSocket.cpp b/folly/io/async/AsyncSSLSocket.cpp index 0b71f845..a0224877 100644 --- a/folly/io/async/AsyncSSLSocket.cpp +++ b/folly/io/async/AsyncSSLSocket.cpp @@ -1384,7 +1384,7 @@ ssize_t AsyncSSLSocket::performWrite(const iovec* vec, return -1; } - bool cork = isSet(flags, WriteFlags::CORK) || persistentCork_; + bool cork = isSet(flags, WriteFlags::CORK); CorkGuard guard(fd_, count > 1, cork, &corked_); #if 0 diff --git a/folly/io/async/AsyncSSLSocket.h b/folly/io/async/AsyncSSLSocket.h index 6cfd24b6..4ab04860 100644 --- a/folly/io/async/AsyncSSLSocket.h +++ b/folly/io/async/AsyncSSLSocket.h @@ -839,6 +839,8 @@ class AsyncSSLSocket : public virtual AsyncSocket { static void sslInfoCallback(const SSL *ssl, int type, int val); + // Whether we've applied the TCP_CORK option to the socket + bool corked_{false}; // SSL related members. bool server_{false}; // Used to prevent client-initiated renegotiation. Note that AsyncSSLSocket diff --git a/folly/io/async/AsyncSocket.cpp b/folly/io/async/AsyncSocket.cpp index 92defa38..2732ace9 100644 --- a/folly/io/async/AsyncSocket.cpp +++ b/folly/io/async/AsyncSocket.cpp @@ -1203,37 +1203,6 @@ int AsyncSocket::setTCPProfile(int profd) { return 0; } -void AsyncSocket::setPersistentCork(bool cork) { - if (setCork(cork) == 0) { - persistentCork_ = cork; - } -} - -int AsyncSocket::setCork(bool cork) { -#ifdef TCP_CORK - if (fd_ < 0) { - VLOG(4) << "AsyncSocket::setCork() called on non-open socket " - << this << "(stats=" << state_ << ")"; - return EINVAL; - } - - if (corked_ == cork) { - return 0; - } - - int flag = cork ? 1 : 0; - if (setsockopt(fd_, IPPROTO_TCP, TCP_CORK, &flag, sizeof(flag)) != 0) { - int errnoCopy = errno; - VLOG(2) << "faield to turn on TCP_CORK option on AsyncSocket" - << this << "(fd=" << fd_ << ", state=" << state_ << "):" - << folly::errnoStr(errnoCopy); - return errnoCopy; - } - corked_ = cork; -#endif - return 0; -} - void AsyncSocket::ioReady(uint16_t events) noexcept { VLOG(7) << "AsyncSocket::ioRead() this=" << this << ", fd" << fd_ << ", events=" << std::hex << events << ", state=" << state_; diff --git a/folly/io/async/AsyncSocket.h b/folly/io/async/AsyncSocket.h index 28c553a5..28f1c65d 100644 --- a/folly/io/async/AsyncSocket.h +++ b/folly/io/async/AsyncSocket.h @@ -465,15 +465,6 @@ class AsyncSocket : virtual public AsyncTransportWrapper { #define SO_SET_NAMESPACE 41 int setTCPProfile(int profd); - /** - * Set TCP_CORK on the socket, and turn on/off the persistentCork_ flag - * - * When persistentCork_ is true, CorkGuard in AsyncSSLSocket will not be - * able to toggle TCP_CORK - * - */ - void setPersistentCork(bool cork); - /** * Generic API for reading a socket option. * @@ -781,13 +772,6 @@ class AsyncSocket : virtual public AsyncTransportWrapper { std::string withAddr(const std::string& s); - /** - * Set TCP_CORK on this socket - * - * @return 0 if Cork is turned on, or non-zero errno on error - */ - int setCork(bool cork); - StateEnum state_; ///< StateEnum describing current state uint8_t shutdownFlags_; ///< Shutdown state (ShutdownFlags) uint16_t eventFlags_; ///< EventBase::HandlerFlags settings @@ -818,11 +802,6 @@ class AsyncSocket : virtual public AsyncTransportWrapper { std::chrono::steady_clock::time_point connectStartTime_; std::chrono::steady_clock::time_point connectEndTime_; - // Whether this connection is persistently corked - bool persistentCork_{false}; - // Whether we've applied the TCP_CORK option to the socket - bool corked_{false}; - BufferCallback* bufferCallback_{nullptr}; }; #ifdef _MSC_VER -- 2.34.1