Replace select(2) with poll(2) #1991
Conversation
6749989
to
ede7e9d
|
Thanks for submitting this. I'm still looking at the changes. Though, would you be able to run it through valgrind, so far I'm getting several Invalid reads on my end, wondering if you are seeing the same on your side? Thank you!
|
|
I'll find some time for this. |
|
I'll take a look at it as well and see what I find. Thanks again! |
|
PR #1993 is required as the first stepping stone to get address sanitisation to work via the clang compiler. |
poll(2) is more modern, more efficient and a lot faster than select(2). The trade-off is that we need to manage the array of struct pollfd we send it a bit more intelligently than just manipulating tables before each call to select(2). This commit adds functions to dynamically resize the allocation needed when new fd's need to be monitored or old ones discarded and then sprinkles them where needed.
|
Should be fixed now. |
|
Merged. Thanks again for fixing this and submitting this PR. I added a fix (98d6947) for a leak on the last fdstate. Let me know if it makes sense adding that free call at point. |
So that means that an fd being monitored wasn't closed. Working out which fd isn't being closed and ensuring it is would be the cleaner approach if you feel that's important. If you ever have plans to open anothe websocket afterwards, you might want to set vars to NULL after freeing them, especially static ones such as fdstate. |
|
I see what you mean, yeah it's definitely not a biggie as it appears it was only upon stopping the server, though, mostly so it doesn't raise any flags on my tests :) I just added a minor commit to NULL in case we ever need to restart it. |
poll(2) is more modern, more efficient and a lot faster than
select(2). The trade-off is that we need to manage the
array of struct pollfd we send it a bit more intelligently
than just manipulating tables before each call to select(2).
This commit adds functions to dynamically resize the allocation
needed when new fd's need to be monitored or old ones discarded
and then sprinkles them where needed.