Replace select() with poll()#249
Merged
Merged
Conversation
Replace inline `select()`/`FD_SET` with `poll()` on non-Windows platforms in `pbpal_check_connect()`. On Linux and macOS `FD_SET` writes to a fixed 1024-bit bitmap and corrupts the stack when a socket fd value exceeds `FD_SETSIZE`. `poll()` has no fd-value limitation. Windows retains `select()` because its `fd_set` is array-based and safe. test(poller): add unit tests for `poll()`-based callback poller Add `pbpal_ntf_callback_poller_poll_unit_test.c` covering init/deinit, save/remove, watch events, poll detection of readable and writable sockets, multiple sockets, socket update, and a high fd number test case (fd=1500) that validates the fix for the `FD_SETSIZE` overflow.
Contributor
Author
|
@pubnub-release-bot release |
Contributor
|
🚀 Release successfully completed 🚀 |
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.
fix(socket): replace
select()withpoll()inpbpal_check_connectReplace inline
select()/FD_SETwithpoll()on non-Windows platforms inpbpal_check_connect(). On Linux and macOSFD_SETwrites to a fixed 1024-bit bitmap and corrupts the stack when a socket fd value exceedsFD_SETSIZE.poll()has no fd-value limitation. Windows retainsselect()because itsfd_setis array-based and safe.test(poller): add unit tests for
poll()-based callback pollerAdd
pbpal_ntf_callback_poller_poll_unit_test.ccovering init/deinit, save/remove, watch events, poll detection of readable and writable sockets, multiple sockets, socket update, and a high fd number test case (fd=1500) that validates the fix for theFD_SETSIZEoverflow.