Skip to content

Commit

Permalink
Allow AsyncServerSocket::bind to be called for multiple addrs (same a…
Browse files Browse the repository at this point in the history
…s for port bind)

Summary: Allow AsyncServerSocket::bind to be called for multiple addrs (same as for port bind)

Reviewed By: yfeldblum

Differential Revision: D18046496

fbshipit-source-id: efde498fbaa02357d7c66905b8c1e5e839062076
  • Loading branch information
dmm-fb authored and facebook-github-bot committed Oct 22, 2019
1 parent 8f2abf7 commit 023744f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions folly/io/async/AsyncServerSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,15 @@ void AsyncServerSocket::bind(
if (ipAddresses.empty()) {
throw std::invalid_argument("No ip addresses were provided");
}
if (!sockets_.empty()) {
throw std::invalid_argument(
"Cannot call bind on a AsyncServerSocket "
"that already has a socket.");
if (eventBase_) {
eventBase_->dcheckIsInEventBaseThread();
}

for (const IPAddress& ipAddress : ipAddresses) {
SocketAddress address(ipAddress.toFullyQualified(), port);
auto fd = createSocket(address.getFamily());

bindSocket(fd, address, false);
bindSocket(fd, address, !sockets_.empty());
}
if (sockets_.size() == 0) {
throw std::runtime_error(
Expand Down

0 comments on commit 023744f

Please # to comment.