summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/accept.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/win32unix/accept.c')
-rw-r--r--otherlibs/win32unix/accept.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/otherlibs/win32unix/accept.c b/otherlibs/win32unix/accept.c
index fdac3e5da..ec7068bd3 100644
--- a/otherlibs/win32unix/accept.c
+++ b/otherlibs/win32unix/accept.c
@@ -29,6 +29,7 @@ CAMLprim value unix_accept(sock)
int oldvalue, oldvaluelen, newvalue, retcode;
union sock_addr_union addr;
socklen_param_type addr_len;
+ int errcode = 0;
oldvaluelen = sizeof(oldvalue);
retcode = getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
@@ -43,13 +44,15 @@ CAMLprim value unix_accept(sock)
enter_blocking_section();
snew = accept(sconn, &addr.s_gen, &addr_len);
leave_blocking_section();
+ if( snew == INVALID_SOCKET )
+ errcode = WSAGetLastError ();
if (retcode == 0) {
/* Restore initial mode */
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
(char *) &oldvalue, oldvaluelen);
}
if (snew == INVALID_SOCKET) {
- win32_maperr(WSAGetLastError());
+ win32_maperr(errcode);
uerror("accept", Nothing);
}
Begin_roots2 (fd, adr)