wez             Sun Oct 13 19:43:21 2002 EDT

  Modified files:              
    /php4/main  network.c php_network.h 
  Log:
  A much better probable fix for #16114.
  
  
Index: php4/main/network.c
diff -u php4/main/network.c:1.76 php4/main/network.c:1.77
--- php4/main/network.c:1.76    Sun Oct 13 19:21:05 2002
+++ php4/main/network.c Sun Oct 13 19:43:21 2002
@@ -16,7 +16,7 @@
    | Streams work by Wez Furlong <[EMAIL PROTECTED]>                   |
    +----------------------------------------------------------------------+
  */
-/* $Id: network.c,v 1.76 2002/10/13 23:21:05 wez Exp $ */
+/* $Id: network.c,v 1.77 2002/10/13 23:43:21 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -849,6 +849,8 @@
 static int php_sockop_close(php_stream *stream, int close_handle TSRMLS_DC)
 {
        php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
+       fd_set wrfds, efds;
+       int n;
 
        if (close_handle) {
 #if HAVE_OPENSSL_EXT
@@ -862,7 +864,18 @@
                }
 #endif
 
-               /* shutdown(sock->socket, 0); */
+               /* prevent more data from coming in */
+               shutdown(sock->socket, SHUT_RD);
+
+               /* make sure that the OS sends all data before we close the connection 
+*/
+               do {
+                       FD_ZERO(&wrfds);
+                       FD_SET(sock->socket, &wrfds);
+                       efds = wrfds;
+               
+                       n = select(sock->socket + 1, NULL, &wrfds, &efds, NULL);
+               } while (n == -1 && php_socket_errno() == EINTR);
+               
                closesocket(sock->socket);
 
        }
Index: php4/main/php_network.h
diff -u php4/main/php_network.h:1.32 php4/main/php_network.h:1.33
--- php4/main/php_network.h:1.32        Sun Oct 13 18:01:40 2002
+++ php4/main/php_network.h     Sun Oct 13 19:43:21 2002
@@ -15,7 +15,7 @@
    | Author: Stig Venaas <[EMAIL PROTECTED]>                              |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_network.h,v 1.32 2002/10/13 22:01:40 wez Exp $ */
+/* $Id: php_network.h,v 1.33 2002/10/13 23:43:21 wez Exp $ */
 
 #ifndef _PHP_NETWORK_H
 #define _PHP_NETWORK_H
@@ -27,6 +27,9 @@
 # undef FD_SETSIZE
 # include "arpa/inet.h"
 # define socklen_t unsigned int
+# define SHUT_RD       SD_RECEIVE
+# define SHUT_WR       SD_SEND
+# define SHUT_RDWR     SD_BOTH
 #else
 # undef closesocket
 # define closesocket close
@@ -60,6 +63,14 @@
 
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+
+/* These are here, rather than with the win32 counterparts above,
+ * since <sys/socket.h> defines them. */
+#ifndef SHUT_RD
+# define SHUT_RD 0
+# define SHUT_WR 1
+# define SHUT_RDWR 2
 #endif
 
 #ifdef HAVE_SYS_TIME_H



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

Reply via email to