Skip to content

Commit d1760fe

Browse files
Shane Fitzpatrickmeta-codesync[bot]
authored andcommitted
Expose enableReuseAddr for consumers to set
Summary: `AsyncServerSocket.h` sets a default of `true` for enableReuseAddr_ [1], which results in sockets being created with `SO_REUSEADDR`. We do not want this to be the case, so this diff exposes a mechanism for proxygen consumers to set this to false. By default I'm keeping it set to `true` for everything, so functionality shouldn't change for existing users. [1] https://www.internalfb.com/code/fbsource/[114ac0fd701a8746f703eebf3efc3e2fc48569d7]/xplat/folly/io/async/AsyncServerSocket.h?lines=1047 Differential Revision: D90789145 fbshipit-source-id: 9ed25853618aa8626ea608cb3140f21eea0c81fb
1 parent f3f4c7e commit d1760fe

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

proxygen/httpserver/HTTPServer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ folly::Expected<folly::Unit, std::exception_ptr> HTTPServer::startTcpServer(
161161
bootstrap_[i].socketConfig.fastOpenQueueSize =
162162
accConfig->fastOpenQueueSize;
163163
}
164+
bootstrap_[i].socketConfig.enableReuseAddr = accConfig->enableReuseAddr;
164165
bootstrap_[i].group(accExe, ioExecutor);
165166
if (accConfig->reusePort) {
166167
bootstrap_[i].setReusePort(true);

proxygen/httpserver/HTTPServerAcceptor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ std::shared_ptr<const AcceptorConfiguration> HTTPServerAcceptor::makeConfig(
4545
ipConfig.allowInsecureConnectionsOnSecureServer;
4646
conf->enableTCPFastOpen = ipConfig.enableTCPFastOpen;
4747
conf->fastOpenQueueSize = ipConfig.fastOpenQueueSize;
48+
conf->enableReuseAddr = opts.enableReuseAddr;
4849
if (ipConfig.ticketSeeds) {
4950
conf->initialTicketSeeds = *ipConfig.ticketSeeds;
5051
}

proxygen/httpserver/HTTPServerOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ class HTTPServerOptions {
222222
*/
223223
bool useZeroCopy{false};
224224

225+
/**
226+
* Allow multiple sockets to bind to the same address:port. Enabled by
227+
* default.
228+
*/
229+
bool enableReuseAddr{true};
230+
225231
/**
226232
* zerocopy enable function
227233
*/

0 commit comments

Comments
 (0)