Remove per-write buffer callback from AsyncSocket
[folly.git] / folly / io / async / AsyncSocket.h
index b7eeafc7eca21b0d2144283c5de974876ac20078..e813216f6405df368da50588ca303c2b6e6a8d62 100644 (file)
@@ -459,6 +459,14 @@ 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.
@@ -765,6 +773,13 @@ 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
@@ -793,6 +808,11 @@ 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};
 };