[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: flawed LuaSocket select()/tcp.receive() interaction ?
- From: Dave Dodge <dododge@...>
- Date: Wed, 22 Nov 2006 07:08:43 -0500
On Mon, Nov 20, 2006 at 07:22:13PM +0100, email@example.com wrote:
> Nonblocking mode should never be necassery when using select(),
> because of the proper behaviour of recv() as I described above.
Just a quick note that this is not necessarily true.
As I recall: for performance reasons Linux sockets are marked readable
when packets arrive, _before_ the packet checksums are tested. So a
corrupt packet can cause select() to report the socket as readable,
and a recv() call can then block when the delayed checksum test causes
the packet to be discarded. I think this has been observed causing
real problems with some UDP-based daemons.
You'll probably find major kernel developers stating that if you need
a recv/read call to not block on Linux, you _must_ use O_NONBLOCK.
They will not guarantee it otherwise. There was a huge argument about
this 2 years ago and I don't recall any plans to change the behavior.
Some revisions of the select() manpage may have a note about it,
though none of my systems do.