Fix select() always timing out in rmc_serv
Summary
I believe I fixed the issue. Trying several things with select()
but I couldn't get it to work. Based on the note in https://man7.org/linux/man-pages/man2/select.2.html saying "All modern applications should instead use poll(2) or epoll(7)", I decided to try an implementation with poll()
seeing as the change is trivial. I am still not sure if the FD_SETSIZE
limitation is the root cause of the issue, but poll()
does seem to work correctly. It is also simpler and more intuitive to work with compared to select()
.
Anyway, I updated the logic to be a bit easier to follow. It should do the exact same thing, apart from:
- Additional logging on error codes (if not needed, I can remove these)
- The socket is now non-blocking. It seems that this is highly recommended as having
select()
/poll()
before doingaccept()
while leavingaccept()
blocking is doing the same thing in multiple places and can apparently also cause race conditions (https://stackoverflow.com/questions/3444729/using-accept-and-select-at-the-same-time)
Also fixed some of the very weird indentations in the file
Additional Required Actions
- Requires manual tests in pre-production: NO
- Requires a documentation update: NO
References
Closes #969 (closed)
Edited by Niels Alexander Buegel