Commit 2e6e2196 authored by Victor Zverovich's avatar Victor Zverovich Committed by Facebook Github Bot

Don't fail on EINPROGRESS error in bind

Summary: Make `AsyncServerSocket` not fail on `EINPROGRESS` in `bind` and fix handling of `errno` there.

Reviewed By: yfeldblum

Differential Revision: D16791566

fbshipit-source-id: 1aeaefb6bae47bf41fd2d20238b716b84d0566d1
parent ce5afdc6
......@@ -305,11 +305,16 @@ void AsyncServerSocket::bindSocket(
sockaddr* saddr = reinterpret_cast<sockaddr*>(&addrStorage);
if (netops::bind(fd, saddr, address.getActualSize()) != 0) {
if (!isExistingSocket) {
closeNoInt(fd);
if (errno != EINPROGRESS) {
// Get a copy of errno so that it is not overwritten by subsequent calls.
auto errnoCopy = errno;
if (!isExistingSocket) {
closeNoInt(fd);
}
folly::throwSystemError(
errnoCopy,
"failed to bind to async server socket: " + address.describe());
}
folly::throwSystemError(
errno, "failed to bind to async server socket: " + address.describe());
}
#if __linux__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment