Adds writer test case for RCU
[folly.git] / folly / io / async / test / AsyncSSLSocketTest.h
index 452d605e6dddcb45b83747f7c7854f19acea8372..7a05fbbc8ea5d995dd0751add4d059643fccdaa4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2012-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@
 #include <condition_variable>
 #include <iostream>
 #include <list>
+#include <memory>
 
 namespace folly {
 
@@ -60,7 +61,7 @@ class SendMsgParamsCallbackBase :
 
   int getFlagsImpl(folly::WriteFlags flags, int /*defaultFlags*/) noexcept
                                                                      override {
-    return oldCallback_->getFlags(flags);
+    return oldCallback_->getFlags(flags, false /*zeroCopyEnabled*/);
   }
 
   void getAncillaryData(folly::WriteFlags flags, void* data) noexcept override {
@@ -88,7 +89,7 @@ class SendMsgFlagsCallback : public SendMsgParamsCallbackBase {
     if (flags_) {
       return flags_;
     } else {
-      return oldCallback_->getFlags(flags);
+      return oldCallback_->getFlags(flags, false /*zeroCopyEnabled*/);
     }
   }
 
@@ -185,7 +186,7 @@ public WriteCallbackBase {
   }
 };
 
-#ifdef MSG_ERRQUEUE
+#ifdef FOLLY_HAVE_MSG_ERRQUEUE
 /* copied from include/uapi/linux/net_tstamp.h */
 /* SO_TIMESTAMPING gets an integer bit field comprised of these values */
 enum SOF_TIMESTAMPING {
@@ -275,7 +276,7 @@ class WriteCheckTimestampCallback :
   bool gotTimestamp_{false};
   bool gotByteSeq_{false};
 };
-#endif // MSG_ERRQUEUE
+#endif // FOLLY_HAVE_MSG_ERRQUEUE
 
 class ReadCallbackBase :
 public AsyncTransportWrapper::ReadCallback {
@@ -578,7 +579,6 @@ class SSLServerAcceptCallback: public SSLServerAcceptCallbackBase {
     }
   }
 
-  // Functions inherited from TAsyncSSLServerSocket::SSLAcceptCallback
   void connAccepted(
     const std::shared_ptr<folly::AsyncSSLSocket> &s)
     noexcept override {
@@ -599,7 +599,6 @@ class SSLServerAcceptCallbackDelay: public SSLServerAcceptCallback {
   explicit SSLServerAcceptCallbackDelay(HandshakeCallback *hcb):
       SSLServerAcceptCallback(hcb) {}
 
-  // Functions inherited from TAsyncSSLServerSocket::SSLAcceptCallback
   void connAccepted(
     const std::shared_ptr<folly::AsyncSSLSocket> &s)
     noexcept override {
@@ -641,7 +640,6 @@ class SSLServerAsyncCacheAcceptCallback: public SSLServerAcceptCallback {
                                              uint32_t timeout = 0):
     SSLServerAcceptCallback(hcb, timeout) {}
 
-  // Functions inherited from TAsyncSSLServerSocket::SSLAcceptCallback
   void connAccepted(
     const std::shared_ptr<folly::AsyncSSLSocket> &s)
     noexcept override {
@@ -666,7 +664,6 @@ class HandshakeErrorCallback: public SSLServerAcceptCallbackBase {
   explicit HandshakeErrorCallback(HandshakeCallback *hcb):
   SSLServerAcceptCallbackBase(hcb)  {}
 
-  // Functions inherited from TAsyncSSLServerSocket::SSLAcceptCallback
   void connAccepted(
     const std::shared_ptr<folly::AsyncSSLSocket> &s)
     noexcept override {
@@ -702,7 +699,6 @@ class HandshakeTimeoutCallback: public SSLServerAcceptCallbackBase {
   explicit HandshakeTimeoutCallback(HandshakeCallback *hcb):
   SSLServerAcceptCallbackBase(hcb)  {}
 
-  // Functions inherited from TAsyncSSLServerSocket::SSLAcceptCallback
   void connAccepted(
     const std::shared_ptr<folly::AsyncSSLSocket> &s)
     noexcept override {
@@ -738,7 +734,6 @@ class ConnectTimeoutCallback : public SSLServerAcceptCallbackBase {
     state = STATE_SUCCEEDED;
   }
 
-  // Functions inherited from TAsyncSSLServerSocket::SSLAcceptCallback
   void connAccepted(
       const std::shared_ptr<folly::AsyncSSLSocket>& s) noexcept override {
     std::cerr << "ConnectTimeoutCallback::connAccepted" << std::endl;
@@ -830,13 +825,13 @@ class BlockingWriteClient :
       bufLen_(2500),
       iovCount_(2000) {
     // Fill buf_
-    buf_.reset(new uint8_t[bufLen_]);
+    buf_ = std::make_unique<uint8_t[]>(bufLen_);
     for (uint32_t n = 0; n < sizeof(buf_); ++n) {
       buf_[n] = n % 0xff;
     }
 
     // Initialize iov_
-    iov_.reset(new struct iovec[iovCount_]);
+    iov_ = std::make_unique<struct iovec[]>(iovCount_);
     for (uint32_t n = 0; n < iovCount_; ++n) {
       iov_[n].iov_base = buf_.get() + n;
       if (n & 0x1) {
@@ -891,7 +886,7 @@ class BlockingWriteServer :
     : socket_(std::move(socket)),
       bufSize_(2500 * 2000),
       bytesRead_(0) {
-    buf_.reset(new uint8_t[bufSize_]);
+    buf_ = std::make_unique<uint8_t[]>(bufSize_);
     socket_->sslAccept(this, std::chrono::milliseconds(100));
   }
 
@@ -1507,4 +1502,4 @@ class EventBaseAborter : public AsyncTimeout {
   EventBase* eventBase_;
 };
 
-}
+} // namespace folly