RE: [PHP-DEV] zend_timeout and the SIGPROF signal

From: Date: Thu, 20 Feb 2003 15:20:24 +0000
Subject: RE: [PHP-DEV] zend_timeout and the SIGPROF signal
Groups: php.dev 
Request: Send a blank email to php-dev+get-94396@lists.php.net to get a copy of this message
Don't call malloc? Wow, that puts some serious restrictions on what an external library can do. :) Couldn't drivers be required to implement something like SQLCancel in ODBC? A mechanism that lets the driver processing the request cancel the query nicely? -----Original Message----- From: Zeev Suraski [mailto:zeev@zend.com] Sent: Thursday, February 20, 2003 8:16 AM To: wmeler@wp-sa.pl Cc: Jeremy Mullin; php-dev@lists.php.net Subject: Re: [PHP-DEV] zend_timeout and the SIGPROF signal At 17:05 20/02/2003, wmeler@wp-sa.pl 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

« previous php.dev (#94396) next »