ID: 16061
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Other web server
Operating System: linux
PHP Version: 4.1.2
New Comment:
Hi
Meanwhile i did some debugging and found several bugs in the
sapi_thttpd_read_post Function, which i have patched. This patch is
just a workaround, because it blocks the server until all POST data is
read. There should be found a more elegant solution.
In the function php_register_var i also found a bug, that i have
patched.
--- php-4.1.2.orig/sapi/thttpd/thttpd.c Tue Aug 7 10:35:54 2001
+++ php-4.1.2.patched/sapi/thttpd/thttpd.c Tue Mar 19 17:22:52
2002
@@ -130,29 +130,52 @@
static int sapi_thttpd_read_post(char *buffer, uint count_bytes
TSRMLS_DC)
{
- size_t read_bytes = 0, tmp;
+ size_t read_bytes = 0;
+ int tmp;
int c;
+ struct timeval timeout;
+ int wait_time = 250; /* milliseconds */
+ int total_wait_time = 30; /* seconds */
+ int retry_start = total_wait_time * 1000 / wait_time;
+ int retry = retry_start;
/* to understand this, read cgi_interpose_input() in libhttpd.c
*/
c = TG(hc)->read_idx - TG(hc)->checked_idx;
+ c = MIN (c, SG(request_info).content_length);
if (c > 0) {
read_bytes = MIN(c, count_bytes);
memcpy(buffer, TG(hc)->read_buf + TG(hc)->checked_idx,
read_bytes);
TG(hc)->checked_idx += read_bytes;
- count_bytes -= read_bytes;
}
-
+
count_bytes = MIN(count_bytes,
- SG(request_info).content_length -
SG(read_post_bytes) - TG(post_off));
+ SG(request_info).content_length -
SG(read_post_bytes));
while (read_bytes < count_bytes) {
- tmp = recv(TG(hc)->conn_fd, buffer + read_bytes,
+ if ( retry < 0)
+ break;
+
+ tmp = recv(TG(hc)->conn_fd, buffer + read_bytes,
count_bytes - read_bytes, 0);
- if (tmp <= 0)
- break;
- read_bytes += tmp;
+
+ if (tmp <= 0) {
+ if ( errno == EINTR )
+ continue;
+
+ if ( errno == EAGAIN) {
+ retry--;
+ timeout.tv_sec = 0; /* sec */
+ timeout.tv_usec = wait_time * 1000; /* microsec */
+ timeout.tv_usec = 0;
+ select (0, NULL, NULL, NULL, &timeout);
+ continue;
+ }
+ break;
+ }
+ read_bytes += tmp;
+ retry = retry_start;
}
-
+
return read_bytes;
}
--- php-4.1.2.orig/ext/session/session.c Tue Feb 26 20:32:52
2002
+++ php-4.1.2.patched/ext/session/session.c Fri Mar 15 16:49:45
2002
@@ -1144,10 +1144,11 @@
}
} else {
convert_to_string_ex(entry);
-
- if ((strcmp(Z_STRVAL_PP(entry), "HTTP_SESSION_VARS") !=
0) ||
- (strcmp(Z_STRVAL_PP(entry), "_SESSION") != 0)) {
- PS_ADD_VARL(Z_STRVAL_PP(entry),
Z_STRLEN_PP(entry));
+ if ( Z_STRVAL_PP(entry) != NULL ) {
+ if ((strcmp(Z_STRVAL_PP(entry),
"HTTP_SESSION_VARS") != 0) &&
+ (strcmp(Z_STRVAL_PP(entry), "_SESSION")
!= 0)) {
+ PS_ADD_VARL(Z_STRVAL_PP(entry),
Z_STRLEN_PP(entry));
+ }
}
}
}
Previous Comments:
------------------------------------------------------------------------
[2002-03-14 07:33:59] [EMAIL PROTECTED]
Hi
I have a problem with POST using thttpd as a webserver. I'm using
php-4.1.2 and thttpd-2.21b.
configure --prefix=/usr/local \ --with-config-file-path=/webmgnt/etc/
\
--with-gettext \
--with-mcrypt \
--enable-ctype \
--enable-wddx \
--with-thttpd=../thttpd-2.21b \
--enable-shared=no
Everything is compiled staticly
When the HTTP header and the POST data are send in one single TCP
packet everything works fine. But when the POST data or even a part of
it is send in an other packet the php-script can't see any of the POST
variables.
It seems that php only analyses the read-buffer that thttpd offers to
php, but fails in reading the missing POST data from the socket.
Thorsten
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16061&edit=1