Skip to content

Fix cli server blocking on accept when using multiple workers #9693

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

Conversation

iluuu1994
Copy link
Member

Fixes GH-9400

@@ -2441,6 +2441,14 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c
retval = FAILURE;
goto out;
}
// server_sock needs to be non-blocking when using multiple processes. Without it, the first process would
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be asserted by a test

Copy link
Member Author

@iluuu1994 iluuu1994 Oct 9, 2022

Choose a reason for hiding this comment

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

Theoretically we could observe the processes with strace, but the bug depends on a race-condition:

  1. OS receives the request
  2. Process 1/2 each
    a. select
    b. accept
    c. Handle other sockets

If 2.a. and 2.b. don't overlap the error is not triggered. A test would thus be unreliable. We barely have any tests for PHP_CLI_SERVER_WORKERS, some testing here is sensible for sure (I'll add that) but reliably testing this specific bug is probably difficult.

Copy link
Member Author

@iluuu1994 iluuu1994 Oct 9, 2022

Choose a reason for hiding this comment

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

I'm having trouble testing this on PHP-8.0, so I'll merge the test just into master. The good thing is that the test seems to catch the problem reported in this issue.

Edit: Sadly it does not.

@iluuu1994 iluuu1994 closed this in d52f045 Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants