Skip to content

Commit 268dd88

Browse files
kinkieyadij
andauthored
Add special handling for WSAECONNRESET
Co-authored-by: Amos Jeffries <[email protected]>
1 parent ffadd22 commit 268dd88

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

compat/xaccept.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ xaccept(int s, struct sockaddr *a, socklen_t *l)
2222
{
2323
SOCKET result;
2424
if ((result = accept(_get_osfhandle(s), a, l)) == INVALID_SOCKET)
25-
{
26-
if (WSAEMFILE == (errno = WSAGetLastError()))
25+
errno = WSAGetLastError();
26+
if (errno == WSAECONNRESET) {
27+
// for Comm::TcpAcceptor::acceptInto() special handling
28+
// Client gave up, or was accept()'d by other SMP worker.
29+
// Linux POSIX API uses the Connection Aborted code for this case.
30+
errno = ECONNABORTED;
31+
} else if (errno == WSAEMFILE) {
32+
// too many open sockets, cannot accept another right now
2733
errno = EMFILE;
34+
}
2835
return -1;
29-
}
3036
else
3137
return _open_osfhandle(result, 0);
3238
}

0 commit comments

Comments
 (0)