On 28/1/21 11:40 am, Matt Kynx wrote:
>
> > However, it will not interrupt long-running C functions such as MySQL 
> >connection
> attempts. 
>
> So in layman's terms, what can it interrupt and what can't it? Just
> userland code, not core or extensions? Apologies if I haven't read
> enough, I got excited.

That's correct, it can only interrupt userland code. That makes it
quite safe compared to set_time_limit(), which can crash if you try to
do things after the timer has expired. With excimer it's as if the
callback were inserted into the running PHP code. You can modify
variables, throw exceptions, etc.

It works in the same way as pcntl_signal(). In PHP 7.1 pcntl_signal()
was rewritten, and we're taking advantage of the facility that was
introduced to support it.

This is probably the limit to what we can do in an extension. If there
was a timer dispatch feature in PHP core, it could be made to
interrupt more things, for example stream_select(). But the C code has
to cooperate with the interruption, otherwise things will get crashy.

-- Tim Starling

Reply via email to