Re: Does apache stop a script mid execution ?
- From: arkascha <no_spam@xxxxxxxxxxx>
- Date: Tue, 22 Jul 2008 14:59:22 +0200
The Natural Philosopher wrote:
arkascha wrote:
Guillermo Antonio Amaral Bastidas wrote:
Hi everybody,
I have a quick and probably dumb question, keep in mind I just
dumped my old love FastCGI + Perl for it's younger hotter friend PHP5.
If the user calls a time consuming script and then stops or refreshes
the browser before the script had time to finish will Apache kill the
script mid execution or will it let it finish ?
I ask this stupid question because this seems to be happening in one
of my sites.
If this is true, is there any way to tell apache to finish what it
was doing ?
Yes, it DOES stop the execution.
That is usually the desired behaviour, since you dont want to spend all
the valuable cpu ressource to produce a result noone is ever going to see
anyway because the client has gone away.
However you can change this behaviour: take a look at the
ignore_user_abort function
that is interesting and worth knowing.
How does it relate to e.g. a script performing a large mysql query?
Hm, interesting question...
I'd say "depends, actually", since it depends, actually :-)
It should depend on two things:
1.) the way you use php in your environment
2.) the way the client is implemented in the php mysql extension and
2.b) how the connection is set up.
In case you use php as cgi-executable the whole process is stopped in case
the server stops the script execution. This means the client (the process)
disconnects from the mysql server which drops the query, unless there is
some hidden feature in mysql you can use to prevent this (I don't know
about that).
Opposed to that if you use php as an apache module (more common nowadays)
the process is usually _not_ terminated but serves subsequent requests to
the http server (unless its maximum request or duration limits have been
reached which is unlikely). In this case it depends on how the mysql
connection is held. I'd say (note: I dont know) that in case of a "normal"
connection the script abortion triggers the connection to be dropped, this
the query to be dropped by the mysql server, just as if you use a command
line client and disconnect during a query (CTRL-C). If, however, you use a
persistent connection (mysql_pconnect() or something close to that) I'd
say that the connection is _not_ dropped, and I am not sure if there is any
mechanism to notify the server that the query is meant to be cancelled. It
should be possible however, since you can do that when using the command
line client...
Have a try and tell us...
arkascha
.
- Follow-Ups:
- Re: Does apache stop a script mid execution ?
- From: The Natural Philosopher
- Re: Does apache stop a script mid execution ?
- References:
- Does apache stop a script mid execution ?
- From: Guillermo Antonio Amaral Bastidas
- Re: Does apache stop a script mid execution ?
- From: arkascha
- Re: Does apache stop a script mid execution ?
- From: The Natural Philosopher
- Does apache stop a script mid execution ?
- Prev by Date: www.nikeadishoes.com
- Next by Date: Re: notice and warning
- Previous by thread: Re: Does apache stop a script mid execution ?
- Next by thread: Re: Does apache stop a script mid execution ?
- Index(es):
Relevant Pages
|