Skip to content

Fix FPM timer event re-registration #4465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nikic
Copy link
Member

@nikic nikic commented Jul 23, 2019

Make sure that fpm_event_add calls inside a timer callback work by unregistering the event from the queue before invoking its callback.

This is an alternative fix for #4460.

@nikic nikic force-pushed the fpm-timer-reregistration branch from 192f374 to 3998723 Compare July 23, 2019 14:03
@plmnikulin
Copy link
Contributor

My manual tests specific to #4460 ("'break' outside of not in the 'loop' or 'switch' contex" and SIGUSR2 flood) work perfectly with this patch. Such fix is better in the sense that fpm_event_set_timer() function starts working as one could expect.

@nikic nikic added the Bug label Jul 24, 2019
@@ -627,7 +627,7 @@ class Tester
$read = [$this->outDesc];
$write = null;
$except = null;
if (stream_select($read, $write, $except, 2 )) {
if (stream_select($read, $write, $except, 3)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it need to be increased?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test case waits one second after sigquit to send sigterm and another second after that to send sigkill, so we need to wait for two seconds for the reload to occur. So the timeout should be larger than two seconds.

@bukka
Copy link
Member

bukka commented Jul 24, 2019

I like it from the quick look. Not sure if it can have any side effects atm. I would be fine with this going to 7.4 and if it's all good, we could back-port it eventually.

@nikic
Copy link
Member Author

nikic commented Jul 30, 2019

Merged as 0ed6c37 in 7.4. After #4461 this change shouldn't be as critical, so letting it bake in 7.4 for a while seems fine.

@nikic nikic closed this Jul 30, 2019
plmnikulin added a commit to plmnikulin/php-src that referenced this pull request Oct 21, 2019
Postpone signal delivery while spawning children.
Prevent the following case:

- Reload (reexec) is in progress.
- New master is forking to start enough children for pools
  where `pm` is not `on-demand`.
- Another `SIGUSR2` is received by the master process.
- Master process switches to reloading state.
- Some child has not set its own signal handlers.
- `SIGQUIT` and `SIGTERM` sent by master process are caught
  by signal handler set by master process and so they are ignored.
- A child is running, it has no reason to finish

Before pull request php#4465 this scenario could cause deadlock,
however with 0ed6c37 reload finishes after `SIGKILL`.

Use sigprocmask() around fork() to avoid race of delivery signal to children
and setting of own signal handlers.

Fixes bug #76601
php-pulls pushed a commit that referenced this pull request Nov 17, 2019
Postpone signal delivery while spawning children.
Prevent the following case:

- Reload (reexec) is in progress.
- New master is forking to start enough children for pools
  where `pm` is not `on-demand`.
- Another `SIGUSR2` is received by the master process.
- Master process switches to reloading state.
- Some child has not set its own signal handlers.
- `SIGQUIT` and `SIGTERM` sent by master process are caught
  by signal handler set by master process and so they are ignored.
- A child is running, it has no reason to finish

Before pull request #4465 this scenario could cause deadlock,
however with 0ed6c37 reload finishes after `SIGKILL`.

Use sigprocmask() around fork() to avoid race of delivery signal to children
and setting of own signal handlers.

Fixes bug #76601
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants