ID: 16061 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Closed Bug Type: Other web server Operating System: linux PHP Version: 4.1.2 New Comment:
Thank you for your bug report. This issue has already been fixed in the latest released version of PHP, which you can download at http://www.php.net/downloads.php User reports that the problem has been addressed in PHP 4.2.2 Previous Comments: ------------------------------------------------------------------------ [2002-08-30 15:52:05] [EMAIL PROTECTED] Confirmed behavior while testing LDAPExplorer V1.17 on RHL 7.3, PHP 4.1.2, and Apache 1.3.23. Uninstalling PHP 4.1.2 and rebuilding PHP from 4.2.2 source solved my problem (register_globals=on must be set for LDAPExplorer to work). ------------------------------------------------------------------------ [2002-03-27 06:19:53] [EMAIL PROTECTED] 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)); + } } } } ------------------------------------------------------------------------ [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
