register_shutdown_function - does not work or i'am stupid ;)

Hey everyone,
i’ve a little Problem with “register_shutdown_function” it just does not work and i can’t help my self so i hope someone here can push me in the right direction.

The following script creates a Lock-File and should delete it when the user abort’s but it doesn’t:
[php]<?php
class Stream
{
var $lock_file = null;
var $lock_handle = null;

function init()
{
	ignore_user_abort(true); //Just to be sure it's ignored
	register_shutdown_function(array(&$this,"shutdown_source")); //shutdown function within this instance of Stream-Class
	$this->start_source(); //Start Function with creates the lock-file

	while (true) //Loop forever
	{
		if (connection_aborted()) break; //abort look when client disconnects (just to be sure)
		echo "."; //output something, just to be sure
		sleep(2); //limit the output
	}
}
function start_source()
{
	$this->lock_file = $_SERVER["DOCUMENT_ROOT"]."/source.lock"; //save path to lock-file, shutdown-function forget working directory
	if (file_exists($this->lock_file)) return; //return if lockfile allready exists
	//$this->lock_handle = fopen($this->lock_file,"w+");
	touch($this->lock_file); //create lock-file
}
function shutdown_source()
{
	//fclose($this->lock_handle);
	unlink($this->lock_file); //delete the lock-file
}

}

$stream = new Stream();
$stream->init();
?>
[/php]

SOLUTION: The ReverseProxy kept the connection alive ! ARGsss !

Sponsor our Newsletter | Privacy Policy | Terms of Service