At 17:05 20/02/2003, [EMAIL PROTECTED] wrote:
----- Original Message -----
> 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

It is impossible to do it in ZTS for malloc - it uses internal lock
which is not a PHP resource. Long jump from signal causes that lock to
be not released and we have beautiful deadlock ...
Then don't call malloc(). Under ZE1 there's not too much that can be done, but with ZE2, emalloc() (almost) never calls malloc() and features lock-free allocation.

Also when you use external library and it is modifying its internal
structures when signal come, cleaning it is impossible (and dangerous).
ZE shouldn't use zend_bailout in signal!!!
It absolutely should.  There's no other clean way to bail out.

Zeev


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to