summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 2dd9d0e023..da4677bc4a 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -2198,6 +2198,21 @@ rb_w32_strerror(int e)
if (e < 0 || e > sys_nerr) {
if (e < 0)
e = GetLastError();
+#if WSAEWOULDBLOCK != EWOULDBLOCK
+ else if (e >= EADDRINUSE && e <= EWOULDBLOCK) {
+ static int s = -1;
+ int i;
+ if (s < 0)
+ for (s = 0; s < (int)(sizeof(errmap)/sizeof(*errmap)); s++)
+ if (errmap[s].winerr == WSAEWOULDBLOCK)
+ break;
+ for (i = s; i < (int)(sizeof(errmap)/sizeof(*errmap)); i++)
+ if (errmap[i].err == e) {
+ e = errmap[i].winerr;
+ break;
+ }
+ }
+#endif
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, &source, e, 0,
buffer, sizeof(buffer), NULL) == 0)