#48429 [NEW]: example for ignore_user_abort() is not working
| From: | carsten_sttgt at gmx dot de | Date: | Fri, 29 May 2009 14:01:29 +0000 |
| Subject: | #48429 [NEW]: example for ignore_user_abort() is not working | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-2319@lists.php.net to get a copy of this message | ||
From: carsten_sttgt at gmx dot de
Operating system: Windows_NT; FreeBSD
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: example for ignore_user_abort() is not working
Description:
------------
Hello,
I think the description for the "Connection Handling" and detecting the
connection status must be better explained.
The example for ignore_user_abort is also not working for me (the break
was never triggered in my tests) and should be changed to a working one
(and the server setup you must have for the example must be explained).
My test environment is Apache 2.2.11 Windows XP/FreeBSD7.2 and PHP 5.2.9
(module, cgi and fastcgi (mod_fgcid))
Then I have test, if the script really is terminated, if the user is
dropping the connection. Following the notes to flush, I'm using ob_flush
and flush() after the echo.
Im accessing the script in the shell with:
$ lwp-request -t 2 http://localhost/abort.php
So the client is disconnecting after 2 second. You can also use telnet or
your browser.
With Script 1, and reading the manual at [1] and [2], I was surprised,
that the file 'abort.txt' was created. Even ignore_user_abort is false and
the connection was dropped after 2 sec.
So I have enhanced the script with a loop (Script 2) and have played with
the variable $loop:
- If I setup PHP as module, I need ~3 additional echo/flush's
till the script is terminated
- If I setup PHP as CGI, I need ~40-80 (not always the same in
each test) additional echo/flush's till the script is terminated
- If I setup PHP as FastCGI, the script was never terminated.
(have test values 1-1000)
Well, so for me, you can't really trust the connection status. And if
someone reads the manual, he must think:
"Hey, if ignore_user_abort is false (PHP default), the script is
terminated if the connection is dropped."
But many times that's not true.
Regards,
Carsten
[1] http://de.php.net/manual/en/function.ignore-user-abort.php
[2] http://de.php.net/manual/en/features.connection-handling.php
Reproduce code:
---------------
Script 1:
---------
<?php
set_time_limit(0);
ignore_user_abort(false);
@unlink('abort.txt');
sleep(10);
echo ' ';
ob_flush();
flush();
file_put_contents('abort.txt', connection_status());
exit;
?>
Script 2:
---------
<?php
set_time_limit(0);
ignore_user_abort(false);
@unlink('abort.txt');
sleep(10);
echo ' ';
ob_flush();
flush();
$loops = 3;
for ($x = 1; $x <= $loops; $x++) {
echo ' ';
ob_flush();
flush();
}
file_put_contents('abort.txt', connection_status());
exit;
?>
--
Edit bug report at http://bugs.php.net/?id=48429&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48429&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48429&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48429&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=48429&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48429&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=48429&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=48429&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=48429&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=48429&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=48429&r=support
Expected behavior: http://bugs.php.net/fix.php?id=48429&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=48429&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=48429&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=48429&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48429&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48429&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=48429&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=48429&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=48429&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=48429&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=48429&r=mysqlcfg