bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] make EAGAIN == EWOULDBLOCK on Windows


From: Bruno Haible
Subject: Re: [PATCH] make EAGAIN == EWOULDBLOCK on Windows
Date: Fri, 3 Oct 2008 16:49:41 +0200
User-agent: KMail/1.5.4

Eric Blake wrote:
> I'm in favor of the patch

OK, that makes 2:1 for Paolo. Patch slightly modified:
  - In errno.in.h: No need to test '#ifndef EWOULDBLOCK'. If mingw in the
    future defines EWOULDBLOCK, we need to adjust our code.
  - In winsock.c: Mapping WSAEWOULDBLOCK to EWOULDBLOCK sounds more logical :-)
  - In strerror.c, the "case WSAEWOULDBLOCK" code is dead code: it cannot
    happen because WSAEWOULDBLOCK is mapped to something else before it
    is ever stored in 'errno'.

The drawback of this move is that

   errno = EWOULDBLOCK;
   perror ("");

now prints "Resource temporarily unavailable", where before it printed
"Operation would block". But that's like on Linux. That's the "feature"
you get by merging two error codes into a single one.

OK to commit this?


2008-10-03  Paolo Bonzini  <address@hidden>
            Bruno Haible  <address@hidden>

        * lib/errno.in.h (EWOULDBLOCK) [win32]: Define to EAGAIN.
        * lib/winsock.c (set_winsock_errno): Map WSAEWOULDBLOCK
        to EWOULDBLOCK.
        * lib/strerror.c: Return an error string for WSAEWOULDBLOCK,
        not EWOULDBLOCK.

--- lib/errno.in.h.orig 2008-10-03 16:41:43.000000000 +0200
+++ lib/errno.in.h      2008-10-03 16:22:25.000000000 +0200
@@ -30,13 +30,15 @@
 /* On native Windows platforms, many macros are not defined.  */
 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 
+/* POSIX says that EAGAIN and EWOULDBLOCK may have the same value.  */
+#  define EWOULDBLOCK     EAGAIN
+
 /* Values >= 100 seem safe to use.  */
 #  define ETXTBSY   100
 #  define GNULIB_defined_ETXTBSY 1
 
 /* These are intentionally the same values as the WSA* error numbers, defined
    in <winsock2.h>.  */
-#  define EWOULDBLOCK     10035
 #  define EINPROGRESS     10036
 #  define EALREADY        10037
 #  define ENOTSOCK        10038
--- lib/winsock.c.orig  2008-10-03 16:41:43.000000000 +0200
+++ lib/winsock.c       2008-10-03 16:23:56.000000000 +0200
@@ -91,6 +91,9 @@
     case WSA_INVALID_PARAMETER:
       errno = EINVAL;
       break;
+    case WSAEWOULDBLOCK:
+      errno = EWOULDBLOCK;
+      break;
     case WSAENAMETOOLONG:
       errno = ENAMETOOLONG;
       break;
--- lib/strerror.c.orig 2008-10-03 16:41:43.000000000 +0200
+++ lib/strerror.c      2008-10-03 16:41:42.000000000 +0200
@@ -49,8 +49,7 @@
 # endif
 
 # if GNULIB_defined_ESOCK /* native Windows platforms */
-    case EWOULDBLOCK:
-      return "Operation would block";
+    /* EWOULDBLOCK is the same as EAGAIN.  */
     case EINPROGRESS:
       return "Operation now in progress";
     case EALREADY:
@@ -134,8 +133,8 @@
     /* WSAEACCES maps to EACCES */
     /* WSAEFAULT maps to EFAULT */
     /* WSAEINVAL maps to EINVAL */
-    /* WSAEMFILE maos to EMFILE */
-    /* WSAEWOULDBLOCK is EWOULDBLOCK */
+    /* WSAEMFILE maps to EMFILE */
+    /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
     /* WSAEINPROGRESS is EINPROGRESS */
     /* WSAEALREADY is EALREADY */
     /* WSAENOTSOCK is ENOTSOCK */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]