[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is there a race condition using socket.select on Win32 ?
- From: Sam Roberts <sroberts@...>
- Date: Mon, 5 Jun 2006 10:24:49 -0700
On Mon, Jun 05, 2006 at 10:05:57AM -0400, Ralph Hempel wrote:
> I'm working my way through writing an application using
> the luaSocket library.
>
> I'm using Lua 5.1 and luaSocket 2.0.1, and have compiled
> and linked under MinGW - and so far things are working, but
> I'm reviewing the code for possible race conditions.
>
> My question has to do with potential race conditions in
> the example on page 78 of the original PiL.
>
> The idea of using socket.select() to wait until something
> interesting happens makes sense, but what happens if the
> socket became readable BETWEEN the original timeout and
> when socket.select() is called?
I can't speak to lua, but select(), if its emulating unix behaviour,
returns immediately if the socket has data to read, not just
when new data arrives.
Sam
> To make things more interesting, what if the socket never
> gets another character once socket.select() is called?
>
> Does socket.select() essentially block forever in this case?
>
> I must add that it's surprising just how much functionality
> you can build in just a few lines of Lua!
>
> Cheers, Ralph