Skip to content

Commit

Permalink
Merge pull request #10306 from MisterDA/sock-wsa-map-error
Browse files Browse the repository at this point in the history
Map WSA error code to Unix errno for sockopt and getsockname functions
  • Loading branch information
dra27 committed Mar 25, 2021
2 parents 414bdec + 332c0a9 commit 31dcf5b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ Working version
- #10185: Consider that IPv6 is always enabled on Windows.
(Antonin Décimo, review by David Allsopp and Xavier Leroy)

- #10306: Map WSA error code to Unix errno for sockopt and getsockname
functions (Antonin Décimo, review by David Allsopp)

### Tools:

- #10139: Remove confusing navigation bar from stdlib documentation.
Expand Down
5 changes: 4 additions & 1 deletion otherlibs/win32unix/getsockname.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ CAMLprim value unix_getsockname(value sock)

addr_len = sizeof(addr);
retcode = getsockname(Socket_val(sock), &addr.s_gen, &addr_len);
if (retcode == -1) uerror("getsockname", Nothing);
if (retcode == -1) {
win32_maperr(WSAGetLastError());
uerror("getsockname", Nothing);
}
return alloc_sockaddr(&addr, addr_len, -1);
}
8 changes: 6 additions & 2 deletions otherlibs/win32unix/sockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ unix_getsockopt_aux(char * name,
}

if (getsockopt(Socket_val(socket), level, option,
(void *) &optval, &optsize) == -1)
(void *) &optval, &optsize) == -1) {
win32_maperr(WSAGetLastError());
uerror(name, Nothing);
}

switch (ty) {
case TYPE_BOOL:
Expand Down Expand Up @@ -199,8 +201,10 @@ unix_setsockopt_aux(char * name,
}

if (setsockopt(Socket_val(socket), level, option,
(void *) &optval, optsize) == -1)
(void *) &optval, optsize) == -1) {
win32_maperr(WSAGetLastError());
uerror(name, Nothing);
}

return Val_unit;
}
Expand Down

0 comments on commit 31dcf5b

Please sign in to comment.