lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Mar 15, 2012 8:56 PM, "Sam Roberts" <vieuxtech@gmail.com> wrote:

> Anyhow, most network programming texts talk about the importance of
> Jay's point. If you expect not to block, you need to set non-blocking,
> as well as use select (poll, epoll, ...).

Standard defensive concurrency habits cover:

1) under-notification. When woken, read everything available as you may only be woken once.

2) spurious wake-up. If you arrange to be woken when something happens, be aware the signal may have showed up for some other reason. So scan your list of sources and don't die if there are zero.

I knew select() as a whole needed to be covered by #2. Your fdsets may be empty. But I was surprised that "fd 7 is ready for writing" can also be spurious. I don't think I ever ran into this but it was counter-intuitive.

Alan Cox gave an example of a window shrinking as a place where fd 7 may have been available for writing at the time of select() but by the time write() happens this may no longer be true.

Jay

Strong authentication just proves which chump is in front of the keyboard.