3 ms·
>>> One of the first rules in the marvelous book The Pragmatic Programmer is "Select() isn't broken". Yeah, but sometimes it is. How come you give this example
by user5994461 8y ago
>>> One of the first rules in the marvelous book The Pragmatic Programmer is "Select() isn't broken". Yeah, but sometimes it is.
How come you give this example just now? This can't be a coincidence. select() just caused us a major production outage.
FYI: select() is broken on pretty much all Linux kernels up to very recent ones. Doesn't work when there are more than 1024 opened file descriptors, not a lot for a server app. Side effects include crashing the application.
- ptr 8y agoWas your problem something other than the FD_SETSIZE limitation of select?
- bogomipz 8y ago>"FYI: select() is broken on pretty much all Linux kernels up to very recent ones." Can you elaborate or might you have some links? What was the cause and resolution?
- zzzcpan 8y agoNo, it's the least broken event notification mechanism on all systems. And it doesn't have a 1024 FDs limit on most systems either, as long as it used directly via syscall or through an event loop library that does that. But in general for all event notification mechanism on all systems, it's incorrect to assume that reported FDs are actually ready, because that could cause a busy waiting loop, and incorrect to assume that unreported FDs are not ready, because that could cause timeouts.
- user5994461 8y agoSee first paragraph in section BUGS. http://man7.org/linux/man-pages/man2/select.2.html http://man7.org/linux/man-pages/man2/select.2.html If you google for select 1024 file descriptors, you will find a ton of issues affecting a ton of libraries. The correction seems to be using poll(), but in our case was to remove the routine that wasn't needed anymore.