/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2014-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.
#define SO_REUSEPORT 15
#endif
+#if defined __linux__ && !defined SO_NO_TRANSPARENT_TLS
+#define SO_NO_TRANSPARENT_TLS 200
+#endif
+
namespace folly {
/**
Destructor());
}
- void setShutdownSocketSet(ShutdownSocketSet* newSS);
+ void setShutdownSocketSet(const std::weak_ptr<ShutdownSocketSet>& wNewSS);
/**
* Destroy the socket.
* time after destroy() returns. They will not receive any more callback
* invocations once acceptStopped() is invoked.
*/
- virtual void destroy();
+ void destroy() override;
/**
* Attach this AsyncServerSocket to its primary EventBase.
/**
* Get the EventBase used by this socket.
*/
- EventBase* getEventBase() const {
+ EventBase* getEventBase() const override {
return eventBase_;
}
}
}
+ /* enable zerocopy support for the server sockets - the s = accept sockets
+ * inherit it
+ */
+ bool setZeroCopy(bool enable);
+
/**
* Bind to the specified address.
*
*
* Throws TTransportException on error.
*/
- void getAddress(SocketAddress* addressReturn) const;
+ void getAddress(SocketAddress* addressReturn) const override;
/**
* Get the local address to which the socket is bound.
* socket's primary EventBase.
*/
int64_t getNumPendingMessagesInQueue() const {
- assert(eventBase_ == nullptr || eventBase_->isInEventBaseThread());
+ if (eventBase_) {
+ eventBase_->dcheckIsInEventBaseThread();
+ }
int64_t numMsgs = 0;
for (const auto& callback : callbacks_) {
numMsgs += callback.consumer->getQueue()->size();
tfoMaxQueueSize_ = maxTFOQueueSize;
}
+ /**
+ * Do not attempt the transparent TLS handshake
+ */
+ void disableTransparentTls() {
+ noTransparentTls_ = true;
+ }
+
/**
* Get whether or not the socket is accepting new connections
*/
*
* Invoke destroy() instead to destroy the AsyncServerSocket.
*/
- virtual ~AsyncServerSocket();
+ ~AsyncServerSocket() override;
private:
enum class MessageType {
*/
class RemoteAcceptor
: private NotificationQueue<QueueMessage>::Consumer {
- public:
+ public:
explicit RemoteAcceptor(AcceptCallback *callback,
ConnectionEventCallback *connectionEventCallback)
: callback_(callback),
connectionEventCallback_(connectionEventCallback) {}
- ~RemoteAcceptor() = default;
+ ~RemoteAcceptor() override = default;
void start(EventBase *eventBase, uint32_t maxAtOnce, uint32_t maxInQueue);
void stop(EventBase* eventBase, AcceptCallback* callback);
- virtual void messageAvailable(QueueMessage&& message);
+ void messageAvailable(QueueMessage&& message) noexcept override;
NotificationQueue<QueueMessage>* getQueue() {
return &queue_;
}
- private:
+ private:
AcceptCallback *callback_;
ConnectionEventCallback* connectionEventCallback_;
}
// Inherited from EventHandler
- virtual void handlerReady(uint16_t events) noexcept {
+ void handlerReady(uint16_t events) noexcept override {
parent_->handlerReady(events, socket_, addressFamily_);
}
bool reusePortEnabled_{false};
bool closeOnExec_;
bool tfo_{false};
+ bool noTransparentTls_{false};
uint32_t tfoMaxQueueSize_{0};
- ShutdownSocketSet* shutdownSocketSet_;
+ std::weak_ptr<ShutdownSocketSet> wShutdownSocketSet_;
ConnectionEventCallback* connectionEventCallback_{nullptr};
};
-} // folly
+} // namespace folly