cvs: php-src(PHP_5_2) /sapi/webjames webjames.c
| From: | Alex Waugh | Date: | Sun, 26 Nov 2006 19:51:23 +0000 |
| Subject: | cvs: php-src(PHP_5_2) /sapi/webjames webjames.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-41748@lists.php.net to get a copy of this message | ||
alexwaugh Sun Nov 26 19:51:23 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/sapi/webjames webjames.c
Log:
MFH: Improve robustness of sending routines
http://cvs.php.net/viewvc.cgi/php-src/sapi/webjames/webjames.c?r1=1.11.2.2&r2=1.11.2.2.2.1&diff_format=u
Index: php-src/sapi/webjames/webjames.c
diff -u php-src/sapi/webjames/webjames.c:1.11.2.2 php-src/sapi/webjames/webjames.c:1.11.2.2.2.1
--- php-src/sapi/webjames/webjames.c:1.11.2.2 Tue Mar 7 22:35:30 2006
+++ php-src/sapi/webjames/webjames.c Sun Nov 26 19:51:23 2006
@@ -27,7 +27,7 @@
#include <unixlib/local.h>
-#define WEBJAMES_SAPI_VERSION "1.0.1"
+#define WEBJAMES_SAPI_VERSION "1.0.2"
typedef struct {
struct connection *conn; /*structure holding all the details of the current request*/
@@ -42,24 +42,44 @@
static int sapi_webjames_ub_write(const char *str, uint str_length TSRMLS_DC)
/*unbuffered write - send data straight out to socket*/
{
- int bytes;
-
- bytes = webjames_writebuffer(WG(conn),str,str_length);
- if (bytes<0) {
- PG(connection_status) = PHP_CONNECTION_ABORTED;
- if (!PG(ignore_user_abort)) {
- zend_bailout();
+ int totalbytes = 0;
+
+ do {
+ int bytes;
+ bytes = webjames_writebuffer(WG(conn),str,str_length);
+ if (bytes<0) {
+ PG(connection_status) = PHP_CONNECTION_ABORTED;
+ if (!PG(ignore_user_abort)) {
+ zend_bailout();
+ }
+ return bytes;
}
- }
- return bytes;
+ str += bytes;
+ str_length -= bytes;
+ totalbytes += bytes;
+ } while (str_length);
+ return totalbytes;
}
static void sapi_webjames_send_header(sapi_header_struct *sapi_header, void *server_context
TSRMLS_DC)
/*send an HTTP header*/
{
+ char *header = sapi_header->header;
+ int len = sapi_header->header_len;
if (WG(conn)->flags.outputheaders) {
- if (sapi_header)
- webjames_writebuffer(WG(conn), sapi_header->header, sapi_header->header_len);
+ while (sapi_header && len > 0) {
+ int bytes;
+ bytes = webjames_writebuffer(WG(conn), header, len);
+ if (bytes<0) {
+ PG(connection_status) = PHP_CONNECTION_ABORTED;
+ if (!PG(ignore_user_abort)) {
+ zend_bailout();
+ }
+ return;
+ }
+ header += bytes;
+ len -= bytes;
+ }
webjames_writestring(WG(conn), "\r\n");
}
}