On timeout, the engine will call zend_bailout(), which performs a
longjmp(). It does unwind the stack, but since we're dealing with C and
not C++ and there are no destructors, it's your responsibility to clean
after yourself. You can do it by properly registering your resources with
PHP's infrastructure (using the Zend Engine memory management, resource
management, etc.), which will be destroyed when the request terminates (in
this case, shortly after the longjmp()). Doing this is a good idea
(read: must) regardless of timeouts, it's the safety net that ensures that
your code will not be leaking memory and/or resources beyond the context of
a single request.

Zeev

At 16:45 20/02/2003, Jeremy Mullin wrote:

I have a question in regards to page timeouts and how the initial
request is terminated.

First, I apologize up front for my ignorance. I am not a php user,
rather a database developer who has customers using php.
I've noticed if a query takes longer than the default 30 seconds to
execute, php returns a timeout message to the user. From what I can
tell, php uses the SIGPROF signal to stop execution when the 30 seconds
has expired. Also, I've found that it doesn't seem to "unwind" the stack
after receiving the SIGPROF signal, instead it just seems to stop dead
in its tracks and the apache process goes back to listening for another
request.
Is my understanding somewhat correct? If so, how do I, as a library
developer, verify that some/all of my state information is returned back
to a usable state after I've been interrupted right in the middle of a
call?
I've included a pseudo-code example of my problem below, in case it
clarifies what I'm trying to say.
TIA,
J.D. Mullin
Advantage Database Server
Consider the following function:
void func( void )
{
1 - set some state flag to 1
2 - call server to do query execution
3 - set some state flag back to 0
}
The php timeout occurs during step 2.
The zend_timeout handler is called.
?? I don't know what happens next, but control never returns to my
function, so the state flag never gets set back to 0 ??
The same apache process continues to accept requests, although the libraries
that were interrupted are now in an unknown state.
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php