wez             Tue Aug 10 09:44:43 2004 EDT

  Modified files:              
    /php-src/main/streams       xp_socket.c 
  Log:
  Fix for #29256 from Dmitry, very slightly modified
  
  
http://cvs.php.net/diff.php/php-src/main/streams/xp_socket.c?r1=1.26&r2=1.27&ty=u
Index: php-src/main/streams/xp_socket.c
diff -u php-src/main/streams/xp_socket.c:1.26 php-src/main/streams/xp_socket.c:1.27
--- php-src/main/streams/xp_socket.c:1.26       Sat Jul 31 12:34:44 2004
+++ php-src/main/streams/xp_socket.c    Tue Aug 10 09:44:43 2004
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: xp_socket.c,v 1.26 2004/07/31 16:34:44 wez Exp $ */
+/* $Id: xp_socket.c,v 1.27 2004/08/10 13:44:43 wez Exp $ */
 
 #include "php.h"
 #include "ext/standard/file.h"
@@ -52,13 +52,49 @@
                return 0;
        }
 
+retry:
        didwrite = send(sock->socket, buf, count, 0);
 
        if (didwrite <= 0) {
-               char *estr = php_socket_strerror(php_socket_errno(), NULL, 0);
+               long err = php_socket_errno();
+               char *estr;
 
+               if (sock->is_blocked && err == EWOULDBLOCK) {
+                       fd_set fdw, tfdw;
+                       int retval;
+                       struct timeval timeout, *ptimeout;
+
+                       FD_ZERO(&fdw);
+                       FD_SET(sock->socket, &fdw);
+                       sock->timeout_event = 0;
+
+                       if (sock->timeout.tv_sec == -1)
+                               ptimeout = NULL;
+                       else
+                               ptimeout = &timeout;
+
+                       do {
+                               tfdw = fdw;
+                               timeout = sock->timeout;
+
+                               retval = select(sock->socket + 1, NULL, &tfdw, NULL, 
ptimeout);
+
+                               if (retval == 0) {
+                                       sock->timeout_event = 1;
+                                       break;
+                               }
+
+                               if (retval > 0) {
+                                       /* writable now; retry */
+                                       goto retry;
+                               }
+
+                               err = php_socket_errno();
+                       } while (err == EINTR);
+               }
+               estr = php_socket_strerror(err, NULL, 0);
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, "send of %ld bytes failed 
with errno=%d %s",
-                               (long)count, php_socket_errno(), estr);
+                               (long)count, err, estr);
                efree(estr);
        }
 

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

Reply via email to