Commit:    af1b90d62ba69953de2065864d2a1284314323ba
Author:    Gustavo Lopes <glo...@nebm.ist.utl.pt>         Sun, 3 Feb 2013 
01:22:44 +0100
Parents:   6ba5d0a4a5b714c048e0ded9933bfef2031f17c2
Branches:  PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=af1b90d62ba69953de2065864d2a1284314323ba

Log:
Fix bug and hopefully build on WinSDK 6.1

There build was failing on rmtools on the sockets extension for two reasons:

  1. IPV6_TCLASS and IPV6_RECVTCLASS not being defined. These are probably
  recent additions to SDK. Windows 7 doesn't event seem to have complete
  support for IPV6_TCLASS, not accepting in WSASendMsg(). The parts that
  needed this constant were not guarded by #ifdefs. They are now.

  2. The constants EWOULDBLOCK and EINPROGRESS not being defined. These
  were only defined in php_network.h, outside of the extension, and not
  all source files included this header. Nevertheless, a macro defined in
  php_sockets.h needed these constants. When this macro was used in files
  that did not include php_network.h, the compilation would fail.
  Surprisingly, the build did not fail when using the 7.1 Windows SDK
  (more likely, the CRT headers used in VC10), as somehow errno.h was
  being included through some other standard header. This would make the
  constant EWOULDBLOCK defined; however, it would be defined to the wrong
  value. In the winsock context, WSAEWOULDBLOCK should be used instead.
  Because we have difficulty using Windows-only constants in the code, we
  (re)define EWOULDBLOCK to WSAEWOULDBLOCK. This has the obvious
  disavantage we may miss problems like this again in the future.

Changed paths:
  M  ext/sockets/php_sockets.h
  M  ext/sockets/sendrecvmsg.c
  M  ext/sockets/windows_common.h


Diff:
diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h
index bad83b3..dd2b993 100644
--- a/ext/sockets/php_sockets.h
+++ b/ext/sockets/php_sockets.h
@@ -27,6 +27,9 @@
 #if HAVE_SOCKETS
 
 #include <php.h>
+#ifdef PHP_WIN32
+# include "windows_common.h"
+#endif
 
 extern zend_module_entry sockets_module_entry;
 #define phpext_sockets_ptr &sockets_module_entry
diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c
index f75fdcd..50b43ec 100644
--- a/ext/sockets/sendrecvmsg.c
+++ b/ext/sockets/sendrecvmsg.c
@@ -115,8 +115,10 @@ static void init_ancillary_registry(void)
                        to_zval_read_int, IPPROTO_IPV6, IPV6_HOPLIMIT);
 #endif
 
+#ifdef IPV6_TCLASS
        PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int,
                        to_zval_read_int, IPPROTO_IPV6, IPV6_TCLASS);
+#endif
 
 #ifdef SO_PASSCRED
        PUT_ENTRY(sizeof(struct ucred), 0, 0, from_zval_write_ucred,
@@ -416,14 +418,16 @@ void php_socket_sendrecvmsg_init(INIT_FUNC_ARGS)
        REGISTER_LONG_CONSTANT("IPV6_RECVHOPOPTS",              
IPV6_RECVHOPOPTS,       CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("IPV6_RECVDSTOPTS",              
IPV6_RECVDSTOPTS,       CONST_CS | CONST_PERSISTENT);
        */
+#ifdef IPV6_RECVTCLASS
        REGISTER_LONG_CONSTANT("IPV6_RECVTCLASS",               
IPV6_RECVTCLASS,        CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("IPV6_TCLASS",                   IPV6_TCLASS,    
        CONST_CS | CONST_PERSISTENT);
+#endif
 
        /*
        REGISTER_LONG_CONSTANT("IPV6_RTHDR",                    IPV6_RTHDR,     
                CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("IPV6_HOPOPTS",                  IPV6_HOPOPTS,   
        CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("IPV6_DSTOPTS",                  IPV6_DSTOPTS,   
        CONST_CS | CONST_PERSISTENT);
        */
-       REGISTER_LONG_CONSTANT("IPV6_TCLASS",                   IPV6_TCLASS,    
        CONST_CS | CONST_PERSISTENT);
 
 #ifdef SCM_RIGHTS
        REGISTER_LONG_CONSTANT("SCM_RIGHTS",                    SCM_RIGHTS,     
                CONST_CS | CONST_PERSISTENT);
diff --git a/ext/sockets/windows_common.h b/ext/sockets/windows_common.h
index c72c698..3a9cb59 100644
--- a/ext/sockets/windows_common.h
+++ b/ext/sockets/windows_common.h
@@ -24,14 +24,7 @@
 #define HAVE_IF_NAMETOINDEX 1
 
 #define IS_INVALID_SOCKET(a)   (a->bsd_socket == INVALID_SOCKET)
-#ifdef EPROTONOSUPPORT
-# undef EPROTONOSUPPORT
-#endif
-#ifdef ECONNRESET
-# undef ECONNRESET
-#endif
-#define EPROTONOSUPPORT        WSAEPROTONOSUPPORT
-#define ECONNRESET             WSAECONNRESET
+
 #ifdef errno
 # undef errno
 #endif
@@ -40,4 +33,88 @@
 #define set_errno(a)   WSASetLastError(a)
 #define close(a)               closesocket(a)
 
-#endif
\ No newline at end of file
+#ifdef ENETUNREACH /* errno.h probably included */
+# undef EWOULDBLOCK
+# undef EINPROGRESS
+# undef EALREADY
+# undef ENOTSOCK
+# undef EDESTADDRREQ
+# undef EMSGSIZE
+# undef EPROTOTYPE
+# undef ENOPROTOOPT
+# undef EPROTONOSUPPORT
+# undef ESOCKTNOSUPPORT
+# undef EOPNOTSUPP
+# undef EPFNOSUPPORT
+# undef EAFNOSUPPORT
+# undef EADDRINUSE
+# undef EADDRNOTAVAIL
+# undef ENETDOWN
+# undef ENETUNREACH
+# undef ENETRESET
+# undef ECONNABORTED
+# undef ECONNRESET
+# undef ENOBUFS
+# undef EISCONN
+# undef ENOTCONN
+# undef ESHUTDOWN
+# undef ETOOMANYREFS
+# undef ETIMEDOUT
+# undef ECONNREFUSED
+# undef ELOOP
+# undef ENAMETOOLONG
+# undef EHOSTDOWN
+# undef EHOSTUNREACH
+# undef ENOTEMPTY
+# undef EPROCLIM
+# undef EUSERS
+# undef EDQUOT
+# undef ESTALE
+# undef EREMOTE
+
+# undef EAGAIN
+#endif
+
+/* section disabled in WinSock2.h */
+#define EWOULDBLOCK             WSAEWOULDBLOCK
+#define EINPROGRESS             WSAEINPROGRESS
+#define EALREADY                WSAEALREADY
+#define ENOTSOCK                WSAENOTSOCK
+#define EDESTADDRREQ            WSAEDESTADDRREQ
+#define EMSGSIZE                WSAEMSGSIZE
+#define EPROTOTYPE              WSAEPROTOTYPE
+#define ENOPROTOOPT             WSAENOPROTOOPT
+#define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
+#define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
+#define EOPNOTSUPP              WSAEOPNOTSUPP
+#define EPFNOSUPPORT            WSAEPFNOSUPPORT
+#define EAFNOSUPPORT            WSAEAFNOSUPPORT
+#define EADDRINUSE              WSAEADDRINUSE
+#define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
+#define ENETDOWN                WSAENETDOWN
+#define ENETUNREACH             WSAENETUNREACH
+#define ENETRESET               WSAENETRESET
+#define ECONNABORTED            WSAECONNABORTED
+#define ECONNRESET              WSAECONNRESET
+#define ENOBUFS                 WSAENOBUFS
+#define EISCONN                 WSAEISCONN
+#define ENOTCONN                WSAENOTCONN
+#define ESHUTDOWN               WSAESHUTDOWN
+#define ETOOMANYREFS            WSAETOOMANYREFS
+#define ETIMEDOUT               WSAETIMEDOUT
+#define ECONNREFUSED            WSAECONNREFUSED
+#define ELOOP                   WSAELOOP
+#define ENAMETOOLONG            WSAENAMETOOLONG
+#define EHOSTDOWN               WSAEHOSTDOWN
+#define EHOSTUNREACH            WSAEHOSTUNREACH
+#define ENOTEMPTY               WSAENOTEMPTY
+#define EPROCLIM                WSAEPROCLIM
+#define EUSERS                  WSAEUSERS
+#define EDQUOT                  WSAEDQUOT
+#define ESTALE                  WSAESTALE
+#define EREMOTE                 WSAEREMOTE
+
+/* and an extra one */
+#define EAGAIN                                 WSAEWOULDBLOCK
+
+#endif


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to