Skip to content

Prevent fiber switching in tick function and signal handlers #9028

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

Merged
merged 3 commits into from
Jul 16, 2022

Conversation

trowski
Copy link
Member

@trowski trowski commented Jul 16, 2022

Switching fibers in these contexts causes unexpected consequences:

  • Switching during a tick will prevent further ticks from being executed until the fiber is resumed.
  • Switching when handing a signal will prevent further signals being handled until the fiber is resumed.

This PR prevents fiber switching in either context. It is possible in the future ticks or signal handling may be modified to be re-entrant, allowing multiple fibers to enter the handler function. Preventing fiber switching gives us greater freedom to define switching behavior in the future should we decide to properly support switching fibers. However, it is my opinion that support for fiber switching is not really necessary in these contexts.

@trowski trowski force-pushed the restrict-fiber-switch branch from fe2d525 to 6baf543 Compare July 16, 2022 15:27
Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Thank you!

However, it is my opinion that support for fiber switching is not really necessary in these contexts.

I concur.

@Alimadadi
Copy link

Alimadadi commented Jul 19, 2022

So, please update the docs too. I have a suggestion:

Fiber::suspend
(PHP 8 >= 8.1.0)
Fiber::suspend — Suspends execution of the current fiber (Well, except if you use it inside of tick functions, because we are too good to leave even a harmless bug open, but also too unwilling to fix issues of features that we don't like enough).

That's sad, really sad.

@staabm
Copy link
Contributor

staabm commented Jul 19, 2022

@Alimadadi feel free to invest your own free time to investigate the bug (or your own money to contract someone doing it for you) and propose a proper solution - instead of judging about other people, investing their own free time to investigate your bugs.

it seems as of now, you are the only one having a use-case for fibers and tick functions in combination.

@Alimadadi
Copy link

Alimadadi commented Jul 19, 2022

@staabm No judge here at all.
What I mean by saying "it's sad", was about not being able to use those features in future inside pure PHP, even if it's buggy.
I think I can continue to use other libraries for my purpose, or comment out a couple of lines before compiling PHP.
And yes, it's open source software, and we are all very thankful of all programmers who share their time for contributing and making a better world 💐.
Maybe I do what you said in future and contribute too.
Peace.

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.

4 participants