projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add TLS 1.2+ version for contexts
[folly.git]
/
folly
/
io
/
async
/
AsyncServerSocket.cpp
diff --git
a/folly/io/async/AsyncServerSocket.cpp
b/folly/io/async/AsyncServerSocket.cpp
index 6b2b9466ee22aa4d53ef5e9661c0b5b6839c0d46..8a70d77cc188701d60875ee0bde36386f8721fe0 100644
(file)
--- a/
folly/io/async/AsyncServerSocket.cpp
+++ b/
folly/io/async/AsyncServerSocket.cpp
@@
-90,8
+90,7
@@
void AsyncServerSocket::RemoteAcceptor::stop(
}
void AsyncServerSocket::RemoteAcceptor::messageAvailable(
}
void AsyncServerSocket::RemoteAcceptor::messageAvailable(
- QueueMessage&& msg) {
-
+ QueueMessage&& msg) noexcept {
switch (msg.type) {
case MessageType::MSG_NEW_CONN:
{
switch (msg.type) {
case MessageType::MSG_NEW_CONN:
{
@@
-183,7
+182,9
@@
int AsyncServerSocket::stopAccepting(int shutdownFlags) {
VLOG(10) << "AsyncServerSocket::stopAccepting " << this <<
handler.socket_;
}
VLOG(10) << "AsyncServerSocket::stopAccepting " << this <<
handler.socket_;
}
- assert(eventBase_ == nullptr || eventBase_->isInEventBaseThread());
+ if (eventBase_) {
+ eventBase_->dcheckIsInEventBaseThread();
+ }
// When destroy is called, unregister and close the socket immediately.
accepting_ = false;
// When destroy is called, unregister and close the socket immediately.
accepting_ = false;
@@
-245,7
+246,7
@@
void AsyncServerSocket::destroy() {
void AsyncServerSocket::attachEventBase(EventBase *eventBase) {
assert(eventBase_ == nullptr);
void AsyncServerSocket::attachEventBase(EventBase *eventBase) {
assert(eventBase_ == nullptr);
-
assert(eventBase->isInEventBaseThread()
);
+
eventBase->dcheckIsInEventBaseThread(
);
eventBase_ = eventBase;
for (auto& handler : sockets_) {
eventBase_ = eventBase;
for (auto& handler : sockets_) {
@@
-255,7
+256,7
@@
void AsyncServerSocket::attachEventBase(EventBase *eventBase) {
void AsyncServerSocket::detachEventBase() {
assert(eventBase_ != nullptr);
void AsyncServerSocket::detachEventBase() {
assert(eventBase_ != nullptr);
-
assert(eventBase_->isInEventBaseThread()
);
+
eventBase_->dcheckIsInEventBaseThread(
);
assert(!accepting_);
eventBase_ = nullptr;
assert(!accepting_);
eventBase_ = nullptr;
@@
-265,7
+266,9
@@
void AsyncServerSocket::detachEventBase() {
}
void AsyncServerSocket::useExistingSockets(const std::vector<int>& fds) {
}
void AsyncServerSocket::useExistingSockets(const std::vector<int>& fds) {
- assert(eventBase_ == nullptr || eventBase_->isInEventBaseThread());
+ if (eventBase_) {
+ eventBase_->dcheckIsInEventBaseThread();
+ }
if (sockets_.size() > 0) {
throw std::invalid_argument(
if (sockets_.size() > 0) {
throw std::invalid_argument(
@@
-281,6
+284,13
@@
void AsyncServerSocket::useExistingSockets(const std::vector<int>& fds) {
SocketAddress address;
address.setFromLocalAddress(fd);
SocketAddress address;
address.setFromLocalAddress(fd);
+#if __linux__
+ if (noTransparentTls_) {
+ // Ignore return value, errors are ok
+ setsockopt(fd, SOL_SOCKET, SO_NO_TRANSPARENT_TLS, nullptr, 0);
+ }
+#endif
+
setupSocket(fd, address.getFamily());
sockets_.emplace_back(eventBase_, fd, this, address.getFamily());
sockets_.back().changeHandlerFD(fd);
setupSocket(fd, address.getFamily());
sockets_.emplace_back(eventBase_, fd, this, address.getFamily());
sockets_.back().changeHandlerFD(fd);
@@
-298,6
+308,7
@@
void AsyncServerSocket::bindSocket(
sockaddr_storage addrStorage;
address.getAddress(&addrStorage);
sockaddr* saddr = reinterpret_cast<sockaddr*>(&addrStorage);
sockaddr_storage addrStorage;
address.getAddress(&addrStorage);
sockaddr* saddr = reinterpret_cast<sockaddr*>(&addrStorage);
+
if (fsp::bind(fd, saddr, address.getActualSize()) != 0) {
if (!isExistingSocket) {
closeNoInt(fd);
if (fsp::bind(fd, saddr, address.getActualSize()) != 0) {
if (!isExistingSocket) {
closeNoInt(fd);
@@
-307,6
+318,13
@@
void AsyncServerSocket::bindSocket(
address.describe());
}
address.describe());
}
+#if __linux__
+ if (noTransparentTls_) {
+ // Ignore return value, errors are ok
+ setsockopt(fd, SOL_SOCKET, SO_NO_TRANSPARENT_TLS, nullptr, 0);
+ }
+#endif
+
// If we just created this socket, update the EventHandler and set socket_
if (!isExistingSocket) {
sockets_.emplace_back(eventBase_, fd, this, address.getFamily());
// If we just created this socket, update the EventHandler and set socket_
if (!isExistingSocket) {
sockets_.emplace_back(eventBase_, fd, this, address.getFamily());
@@
-314,7
+332,9
@@
void AsyncServerSocket::bindSocket(
}
void AsyncServerSocket::bind(const SocketAddress& address) {
}
void AsyncServerSocket::bind(const SocketAddress& address) {
- assert(eventBase_ == nullptr || eventBase_->isInEventBaseThread());
+ if (eventBase_) {
+ eventBase_->dcheckIsInEventBaseThread();
+ }
// useExistingSocket() may have been called to initialize socket_ already.
// However, in the normal case we need to create a new socket now.
// useExistingSocket() may have been called to initialize socket_ already.
// However, in the normal case we need to create a new socket now.
@@
-413,6
+433,13
@@
void AsyncServerSocket::bind(uint16_t port) {
SocketAddress::getFamilyNameFrom(res->ai_addr, "<unknown>"));
}
SocketAddress::getFamilyNameFrom(res->ai_addr, "<unknown>"));
}
+#if __linux__
+ if (noTransparentTls_) {
+ // Ignore return value, errors are ok
+ setsockopt(s, SOL_SOCKET, SO_NO_TRANSPARENT_TLS, nullptr, 0);
+ }
+#endif
+
SocketAddress address;
address.setFromLocalAddress(s);
SocketAddress address;
address.setFromLocalAddress(s);
@@
-484,7
+511,9
@@
void AsyncServerSocket::bind(uint16_t port) {
}
void AsyncServerSocket::listen(int backlog) {
}
void AsyncServerSocket::listen(int backlog) {
- assert(eventBase_ == nullptr || eventBase_->isInEventBaseThread());
+ if (eventBase_) {
+ eventBase_->dcheckIsInEventBaseThread();
+ }
// Start listening
for (auto& handler : sockets_) {
// Start listening
for (auto& handler : sockets_) {
@@
-518,7
+547,9
@@
std::vector<SocketAddress> AsyncServerSocket::getAddresses()
void AsyncServerSocket::addAcceptCallback(AcceptCallback *callback,
EventBase *eventBase,
uint32_t maxAtOnce) {
void AsyncServerSocket::addAcceptCallback(AcceptCallback *callback,
EventBase *eventBase,
uint32_t maxAtOnce) {
- assert(eventBase_ == nullptr || eventBase_->isInEventBaseThread());
+ if (eventBase_) {
+ eventBase_->dcheckIsInEventBaseThread();
+ }
// If this is the first accept callback and we are supposed to be accepting,
// start accepting once the callback is installed.
// If this is the first accept callback and we are supposed to be accepting,
// start accepting once the callback is installed.
@@
-564,7
+595,9
@@
void AsyncServerSocket::addAcceptCallback(AcceptCallback *callback,
void AsyncServerSocket::removeAcceptCallback(AcceptCallback *callback,
EventBase *eventBase) {
void AsyncServerSocket::removeAcceptCallback(AcceptCallback *callback,
EventBase *eventBase) {
- assert(eventBase_ == nullptr || eventBase_->isInEventBaseThread());
+ if (eventBase_) {
+ eventBase_->dcheckIsInEventBaseThread();
+ }
// Find the matching AcceptCallback.
// We just do a simple linear search; we don't expect removeAcceptCallback()
// Find the matching AcceptCallback.
// We just do a simple linear search; we don't expect removeAcceptCallback()
@@
-627,7
+660,9
@@
void AsyncServerSocket::removeAcceptCallback(AcceptCallback *callback,
}
void AsyncServerSocket::startAccepting() {
}
void AsyncServerSocket::startAccepting() {
- assert(eventBase_ == nullptr || eventBase_->isInEventBaseThread());
+ if (eventBase_) {
+ eventBase_->dcheckIsInEventBaseThread();
+ }
accepting_ = true;
if (callbacks_.empty()) {
accepting_ = true;
if (callbacks_.empty()) {
@@
-645,7
+680,9
@@
void AsyncServerSocket::startAccepting() {
}
void AsyncServerSocket::pauseAccepting() {
}
void AsyncServerSocket::pauseAccepting() {
- assert(eventBase_ == nullptr || eventBase_->isInEventBaseThread());
+ if (eventBase_) {
+ eventBase_->dcheckIsInEventBaseThread();
+ }
accepting_ = false;
for (auto& handler : sockets_) {
handler. unregisterHandler();
accepting_ = false;
for (auto& handler : sockets_) {
handler. unregisterHandler();
@@
-1002,7
+1039,8
@@
void AsyncServerSocket::backoffTimeoutExpired() {
// the backoff timeout.
assert(accepting_);
// We can't be detached from the EventBase without being paused
// the backoff timeout.
assert(accepting_);
// We can't be detached from the EventBase without being paused
- assert(eventBase_ != nullptr && eventBase_->isInEventBaseThread());
+ assert(eventBase_ != nullptr);
+ eventBase_->dcheckIsInEventBaseThread();
// If all of the callbacks were removed, we shouldn't re-enable accepts
if (callbacks_.empty()) {
// If all of the callbacks were removed, we shouldn't re-enable accepts
if (callbacks_.empty()) {
@@
-1032,6
+1070,4
@@
void AsyncServerSocket::backoffTimeoutExpired() {
}
}
}
}
-
-
-} // folly
+} // namespace folly