Hi,

APR doesn't use gai_strerror() on Windows (because it's not thread
safe) and apr_streror() return "APR does not understand this code"
message for failed apr_socket_addr_get() calls. It's not user
friendly.

Please find attached patch to use apr_get_netos_error()  to get error
code from getaddrinfo() function on Windows as documented in MSDN:
http://msdn.microsoft.com/en-us/library/ms738520%28v=vs.85%29.aspx
[[[
Use the gai_strerror function to print error messages based on the EAI
codes returned by the getaddrinfo function. The gai_strerror function
is provided for compliance with IETF recommendations, but it is not
thread safe. Therefore, use of traditional Windows Sockets functions
such as WSAGetLastError is recommended.
]]]

Thanks in advance.

-- 
Ivan Zhakov
Index: network_io/unix/sockaddr.c
===================================================================
--- network_io/unix/sockaddr.c  (revision 1082932)
+++ network_io/unix/sockaddr.c  (working copy)
@@ -371,12 +371,13 @@
     }
 #endif
     if (error) {
-#ifndef WIN32
+#if defined(WIN32)
+        return apr_get_netos_error();
+#else
         if (error == EAI_SYSTEM) {
             return errno;
         }
         else 
-#endif
         {
             /* issues with representing this with APR's error scheme:
              * glibc uses negative values for these numbers, perhaps so 
@@ -388,6 +389,7 @@
 #endif
             return error + APR_OS_START_EAIERR;
         }
+#endif /* WIN32 */
     }
 
     prev_sa = NULL;

Reply via email to