[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: select() timeout
In article <20120227082352.GA20549%colwyn.zhadum.org.uk@localhost>,
Matthias Scheler <tron%zhadum.org.uk@localhost> wrote:
>On Sun, Feb 19, 2012 at 07:33:53PM -0500, James K. Lowden wrote:
>> Matthias Scheler <tron%zhadum.org.uk@localhost> wrote:
>> > And select(2) is a dangerous API.
>> Dangerous how? When the filehandle count is controlled,
>It is not the number of file descriptors that matter but the highest
>file descriptor number.
>> ... what problem does it present?
>I've see select(2) blanking a huge portion of stack space under Linux
>because OpenSSL got a file descriptor number outside of FD_SETSIZE.
>The author of this bit of code had just like you assumed that nothing
>could go wrong when you use select(2) to handle a single file descriptor.
>Newer version of OpenSSL use poll(2).
>> select(2) is the oldest and most portable of its kind. It's not hard
>> to find C libraries that do not support poll or kqueue.
I would definitely not call select portable, and there are a lot
of libraries out there that implement select on top of poll and
1. Expensive because you need do operations on bitmasks [ffs/shifts].
2. Expensive because you need to reset the masks before each call.
3. Can only report 3 types of events, read/write/except.
4. Non portable behavior for >= 256 fd's. All systems need source
recompilation; some older systems need kernel recompilation.
5. Non-portable behavior with respect to ERESTART; it is unspecified what
happens when the interrupting signal has SA_RESTART set.
6. Non-portable behavior when running out of resources. The only
way to fix this is using non-blocking-I/O which is a bit of a pain.
7. Non-portable behavior with respect to "struct timeval *timeout".
This is non-const, and it was originally intended to return
the time left. Most implementations did not change "timeout", but
one or two did, so it is always good to re-initialize "timeout".
8. Non-portable behavior as to what is the maximum timeout value supported.
9. Non-portable behavior for descriptor types other than regular files
Main Index |
Thread Index |