|
Posted by Erwin Moller on 10/13/43 11:39
a wrote:
> I already posted on this subject, but I have some more information that
> should make the issue clearer.
>
> Config: Apache 2.x, PHP 5.1.x, Windows XP Pro
>
> A php script processes a form. Inside this script I call exec to run a
> Windows process. If I press the submit button on the form repeatedly, exec
> starts and exit the process several times, but after 2-3 cycles, it starts
> the process, the process exits, but exec doesn't return, and it hangs the
> script and the session forever - it won't even timeout.
Hi,
No timeout?
That sucks.
Maybe it has to do with multiple requests having the same sessionid
(PHPSESSID).
If you have a default install, you'll have filebased sessionstorage, and
just the default sessionhandlingfunctions (No databasesessionstorage or own
functions).
I am not sure if this will help you solve the problem, but here is some
backgroundinformation:
I am unsure how things are implemented under Win XP, but under *nix the
following happens:
1) Request 1 (carrying some PHPSESSID) arives at the server.
2) Server tries to open AND LOCK (flock()) the sessionfile to load the
sessiondata into the scriptenvironment.
3) Script terminates, and the (possibly changed) sessiondata is written to
the file.
This process repeats itself.
If however a request arives at the server that carries a sessionid of a file
that is already open (LOCKED), this requests WAITS untill the file gets
unlocked.
In this way you prevent multiple request to corrupt the sessionfile by
simultanious writes to the same file, possibly all with other data.
I suspect that you somehow leave the sessionfile locked with your systemcall
that is not returning.
You can check this by:
1) determining the sessionid (Just ask your browser for the value of
PHPSESID)
2) Look up the corresponding file (in some temp-directory as mentioned in
php.ini)
3) Try to open and write to this file, by hand.
If it is locked, you will not be able to.
This is a *nix story.
BUT, I am unsure how things work on XP. :-(
Hope this helps you getting started with debugging.
Sessionrelated problems tend to be hard to debug because most of the action
go on before the script start, and after the script finishes.
Regards,
Erwin Moller
>
> I tried to block multiple POSTs by using a global var:
>
> if( isset( $_SESSION[ "processing" ] ) )
> {
> // 1
> exit;
> }
> else
> {
> $_SESSION[ "processing" ] = true;
> exec( ...);
> unset( _SESSION[ "processing" ] );
> }
>
> but the script never reaches //1.
>
> I am totally confused by this reentrancy issue and I don't know how to
> handle:
> 1. multiple posts while the script is still running, to avoid hanging the
> session
> 2. offering the ability to cancel the processing, if the process takes a
> long time.
>
> One of the requirements is that all processing happen on the server, so no
> JavaScript is allowed.
>
> A related question - can multiple php scripts run simultaneously in the
> same session -if a user presses submit multiple times, does this run new
> instance of the script for each POST?
>
> I would really appreciate any help.
>
> Thanks,
>
> A
Navigation:
[Reply to this message]
|