Req #43219 [Com]: connection_status() can function properly without output
| From: | danclax at rambler dot ru | Date: | Thu, 16 Aug 2012 17:12:21 +0000 |
| Subject: | Req #43219 [Com]: connection_status() can function properly without output | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-172643@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=43219&edit=1
ID: 43219
Comment by: danclax at rambler dot ru
Reported by: php at alterego dot dp dot ua
Summary: connection_status() can function properly without
output
Status: Open
Type: Feature/Change Request
Package: Output Control
Operating System: Any
PHP Version: 5.2.5RC2
Block user comment: N
Private report: N
New Comment:
PHP 5.3.3, Apache 2.2.15, CentOS 6.2 x86 - issue reproducible! I can't believe it! Bug persists
5 years. For me it's vital feature.
Previous Comments:
------------------------------------------------------------------------
[2007-11-08 23:28:52] php at alterego dot dp dot ua
Description:
------------
Please regard this comment seriously, it really contains information on how to fix 25266, 22072,
30301 and many other (NOT bogus) bugs under Apache SAPI.
From bug 25266 comment by iliaa@php.net:
> Apache provides a way for PHP to detect if connection was
> aborted ONLY and ONLY when PHP is either reading data from
> the user or writing back data.
That is not true.
This link contains description and code (mod_perl) on how to detect disconnection without flushing
data:
http://www.webreference.com/programming/perl/cookbook/chap4/5.html
My untidy but WORKING solution was to add code given below to sapi_apache_flush function and call
flush() function before connection_aborted() checks WITHOUT any output. Of course, it would be
perfectly logical to add it to connection_aborted function itself, but I could not find any way to
call SAPI-specific function from core.
Working code is:
int fd;
struct timeval tv = {0,0};
fd_set set;
if (server_context) {
request_rec *r = SG(server_context);
fd = ap_bfileno(r->connection->client, B_WR);
if (fd >= 0) {
FD_ZERO(&set);
FD_SET(fd, &set);
if (select(fd + 1, &set, NULL, NULL, &tv) >= 0 && FD_ISSET(fd, &set))
{
php_handle_aborted_connection();
}
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=43219&edit=1