php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28195 Connection handling NEVER works well
Submitted: 2004-04-27 23:26 UTC Modified: 2005-01-15 01:00 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: wesleygoku at hotmail dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 4.3.6 OS: Windows 2000 SP4 + Apache 2.0.49
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wesleygoku at hotmail dot com
New email:
PHP Version: OS:

 

 [2004-04-27 23:26 UTC] wesleygoku at hotmail dot com
Description:
------------
The funcions connection_aborted(), connection_status() and register_shutdown_function never work well. Using an infinite while (while (true)) to make my WebChat work, even the user stopping the page load, the script keep running (even when I set ignore_user_abort(0)). When I tried to check the connection with these functions, they always returnet TRUE, or NORMAL, even the register_shutdown_function callback funcion ISN'T called.

And every bug report of this problem says it was corrected (since 2002), but I'm using it TODAY (with everything updated) and the problem persists!

I'm using PHP 4.3.6 as an Apache 2.0.49 module.

Reproduce code:
---------------
set_time_limit(0);
ignore_user_abort(0);
register_shutdown_function("chat_quit");

function chat_quit () {
	// some code
	exit;
}

echo "<!-- "; for ($i = 0; $i < 20480; $i++) {echo rand(0, 9); } echo " -->\n";
flush();

while (true) {
	// Infinite code
}

Expected result:
----------------
When the user hits 'stop', the function 'chat_quit' should be called. Even if I change 'while (true)' to 'while (!connection_aborted())' the loop continues.

Actual result:
--------------
The function is NEVER called.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-28 09:09 UTC] derick@php.net
Does it work with apache 1.3.29?
 [2004-04-28 20:40 UTC] wesleygoku at hotmail dot com
I can't try under Apache 1.2.29 unless I reinstall this older version of Apache and reconfigure all the server - which I can't.

I expected this problem fixed under the new Apache 2.0, which has better support on Windows.
 [2004-04-28 21:11 UTC] derick@php.net
Apache 2 is not ready for production, so you're out of luck here.
 [2004-08-14 20:41 UTC] z at tzib dot net
Apache2 works very well with PHP in most/all cases.
register_shutdown_function never worked for me in PHP4.X
I just upgraded to PHP5.0.0 and guess what! it works, well, partly:
I use the latest Apache2, and the shutdown function *gets* called (woah :p) and connection_abort *does* return the right value !

But, as I said, just partly working. For some reason I don't know about, if your code in the shutdown function is too large or something, or access variable, (its quite weird so im unable to tell what it is exactly), then it doesn't gets executed.
Eg, I go PHP launching an application and reading stdout. when the guy close the page i want to kill the app, so i close the fd'd, call proc_terminate and proc_close .. nothing happens. So i tried system("kill -9 ".$pid) (i took the pid as global from another part of the code), and never gets executed either it seems..
So i did system("killall appname"); and this one does works

Another weird thing is that php takes 20secs or more to trigger the shutdown function once the page is closed.
 [2005-01-15 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC