win,signal: fix data race dispatching SIGWINCH#4488
Merged
vtjnash merged 1 commit intolibuv:v1.xfrom Aug 5, 2024
Merged
Conversation
The Event should be reset before reading the value, or libuv might miss an update that occurred too rapidly after the previously one. Refs: libuv#2381 Refs: libuv#4485
saghul
approved these changes
Aug 2, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Event should be reset before reading the value, or libuv might miss an update that occurred too rapidly after the previously one.
This thread and the delay here seems to have been added in #2381 by @bzoz, but I don't see a justification there for why 30 fps is correct, or why libuv shouldn't just assume the system will limit to the USB polling and thread-switching frequencies anyways. In libuv, it seems to be causing strictly more work for the system by limiting it to 30 fps, since it has to jump through an extra thread, when SIGWINCH should be coalescing these events anyways. I am somewhat inclined thus to say we should just delete the extra thread and the delay (alternatively, libuv could also use MsgWaitForMultipleEvents with a 33 ms timeout to avoid the thread in the implementation). Additionally, since this hook has been known to cause some performance problems for the rest of the OS, we may want to consider deactivating the hook whenever SIGWINCH is not active, and reactivating it only when SIGWINCH is active.
Refs: #4485