GNOME Bugzilla – Bug 324943
MinGW non-blocking socket communication fails
Last modified: 2006-01-04 09:52:41 UTC
Please describe the problem: The non-blocking socket communication using nanohttp doesn't work for the MinGW platform because EWOULDBLOCK gets redefined to EAGAIN by errno.h if included after wsockcompat.h. But it must be defined to WSAEWOULDBLOCK to ensure that the connection doesn't fail. Steps to reproduce: 1. xmlNanoHTTPOpen fails - regardless of the requested page Actual results: The returned handle is NULL. Expected results: The connection should be established. Does this happen every time? Yes Other information: I'll add a patch later.
Created attachment 56362 [details] [review] Fix for this bug The patch is quite simple. It ensures that <errno.h> gets included in wsockcompat.h and - to avoid warnings - undefines EWOULDBLOCK before the redefinition with WSAEWOULDBLOCK. This has two effects: 1. <errno.h> doesn't get included later by other header files 2. The redefinition doesn't cause a warning Tested with MinGW 5.0
Tested on MinGW 5.0, but on nothing else I assume. Please provide patches making the fix *only* on MinGW and not perturbing compilation with other compilers, as-is this doesn't look acceptable because it forces to do the #include and redefine a core macro for all compilers. I don't want thousands of failure reports from people using the usual compiler. Daniel
Comment on attachment 56362 [details] [review] Fix for this bug Index: include/wsockcompat.h =================================================================== RCS file: /cvs/gnome/libxml2/include/wsockcompat.h,v retrieving revision 1.2 diff -u -r1.2 wsockcompat.h --- include/wsockcompat.h 13 Oct 2005 23:12:42 -0000 1.2 +++ include/wsockcompat.h 27 Dec 2005 10:33:06 -0000 @@ -17,6 +17,13 @@ #endif #endif +#ifdef __MINGW32__ +/* Include <errno.h> here to ensure that it doesn't get included later + * (e.g. by iconv.h) and overwrites the definition of EWOULDBLOCK. */ +#include <errno.h> +#undef EWOULDBLOCK +#endif + #if !defined SOCKLEN_T #define SOCKLEN_T int #endif
Comment on attachment 56362 [details] [review] Fix for this bug Don't use this patch. I'll attach a new version. BTW: How can I delete/modify this attachement?
Created attachment 56430 [details] [review] Second version of the patch fixing this problem. This patch is almost the same as the previous one but it'll only affect the MinGW platform (and not all Win32 ones).
Looks good, applied, will commit soon ! thanks ! Daniel