dmitry          Wed Apr 26 11:08:23 2006 UTC

  Modified files:              
    /php-src/sapi/cgi   fastcgi.c 
  Log:
  Fixed bug #37205 (Serving binary content/images fails with "comm with server 
aborted" FastCGI err)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.8&r2=1.9&diff_format=u
Index: php-src/sapi/cgi/fastcgi.c
diff -u php-src/sapi/cgi/fastcgi.c:1.8 php-src/sapi/cgi/fastcgi.c:1.9
--- php-src/sapi/cgi/fastcgi.c:1.8      Mon Apr 24 09:56:56 2006
+++ php-src/sapi/cgi/fastcgi.c  Wed Apr 26 11:08:23 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: fastcgi.c,v 1.8 2006/04/24 09:56:56 dmitry Exp $ */
+/* $Id: fastcgi.c,v 1.9 2006/04/26 11:08:23 dmitry Exp $ */
 
 #include "fastcgi.h"
 #include "php.h"
@@ -618,8 +618,12 @@
                        RevertToSelf();
                }
 #else
+#if 1
+               shutdown(req->fd, 2);
+#else
                close(req->fd);
 #endif
+#endif
                req->fd = -1;
        }
 }
@@ -814,16 +818,30 @@
                memcpy(req->out_pos, str + limit, len - limit);
                req->out_pos += len - limit;
        } else {
-               int pad = ((len + 7) & ~7) - len;
+               int pos = 0;
+               int pad;
 
+               close_packet(req);
+               while ((len - pos) > 0xffff) {
+                       open_packet(req, type);
+                       fcgi_make_header(req->out_hdr, type, req->id, 0xfff8);
+                       req->out_hdr = NULL;
+                       fcgi_flush(req, 0);
+                       if (safe_write(req, str + pos, 0xfff8) != 0xfff8) {
+                               req->keep = 0;
+                               return -1;
+                       }
+                       pos += 0xfff8;
+               }               
+               
+               pad = (((len - pos) + 7) & ~7) - (len - pos);
                rest = pad ? 8 - pad : 0;
 
-               close_packet(req);
                open_packet(req, type);
-               fcgi_make_header(req->out_hdr, type, req->id, len - rest);
+               fcgi_make_header(req->out_hdr, type, req->id, (len - pos) - 
rest);
                req->out_hdr = NULL;
                fcgi_flush(req, 0);
-               if (safe_write(req, str, len - rest) != len - rest) {
+               if (safe_write(req, str + pos, (len - pos) - rest) != (len - 
pos) - rest) {
                        req->keep = 0;
                        return -1;
                }

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

Reply via email to