#48429 [Opn->WFx]: example for ignore_user_abort() is not working

From: Date: Mon, 16 Nov 2009 13:41:39 +0000
Subject: #48429 [Opn->WFx]: example for ignore_user_abort() is not working
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3193@lists.php.net to get a copy of this message
ID: 48429 Updated by: vrana@php.net Reported By: carsten_sttgt at gmx dot de -Status: Open +Status: Wont fix Bug Type: Documentation problem Operating System: Windows_NT; FreeBSD PHP Version: Irrelevant New Comment: The script will terminate but not necessarily immediately. Previous Comments: ------------------------------------------------------------------------ [2009-05-29 14:01:29] carsten_sttgt at gmx dot de 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 this bug report at http://bugs.php.net/?id=48429&edit=1

« previous php.doc.bugs (#3193) next »