RE: Long running db queries and the "STOP" button

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jochem, 

Thanks for replying 

> I just had the idea (never tried it myself) that you could possibly
> fork the request process and let the child process perform the query

It makes perfectly sense to us, but it seems it is only possible to fork
(pcntl_fork) with php running as CGI :(

>From php.net:
<snip>
arnold at helderhosting dot nl
13-Feb-2005 10:12 
It is not possible to use the function 'pcntl_fork' when PHP is used as
Apache module. You can only use pcntl_fork in CGI mode or from
command-line.

Using this function will result in: 'Fatal error: Call to undefined
function: pcntl_fork()'
<snip>

This somehow makes sense, because one would fork the entire apache
process, 
Including all the signal handlers, open file handles for log-files and
so on...

Furthermore fork is only supported on linux/*nix but not in the windows
world, and it has to be enabled at configure time.

We have so far tried to use javascript to detect when a windows is
closed and send a second HTTP request to kill the database thread. This
however does not work reliably, because javascript has no event for the
"Stop" button of the browser :(

The next idea is to include a <img src="monitorscript.php"> in output
generated by the query script. This should open a second HTTP connection
to the monitor script on most recent browsers. In this script we can
check connection_aborted() and sleep(1) in a while loop without sending
any output. If the connection was aborted, we can kill the corresponding
db thread. 

The remaining problem with that solution is that we also have to detect
when the db query script has terminated and then exit the monitor
script. Otherwise the browser keeps loading that monitorscript and never
finishes.
This solution has two drawbacks, it work over a http proxy (these tend
to finish queries in order to cache the content) and it works only when
the browser is doing several queries in parallel.

Cheers,
Thomas

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux