apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Norris <...@cataclysm.cx>
Subject Re: PATCH: Determine how many bytes are waiting to be read from a socket
Date Sun, 14 Mar 2004 08:13:22 GMT
On Thu, Mar 04, 2004 at 11:48:52PM -0600, Scott Lamb wrote:
> >Interesting. I've never actually seen select() and friends do this, but
> >of course there's lots of broken OSes out there.
> 
> Well, they don't even consider it to be broken. I've found the message  
> in question:
> 
> <http://groups.google.com/groups?q=select+hint+group: 
> linux.kernel&hl=en&lr=lang_en&ie=UTF-8&oe=UTF 
> -8&group=linux.kernel&c2coff=1&safe=off&selm=20030609031009%2414ba%40gat

> ed-at.bofh.it&rnum=1>

There's some logic in that explanation. I can accept it :)

> >I want a basic I/O event layer that tells the application
> >above it when something interesting happens on a socket (ie something  
> >to
> >read, ready to write, closed). If the event layer has to read data to
> >find this out, then this abstraction doesn't work.
> 
> Is distinguishing close really that important? What select() tells you  
> is that you can probably do a read() or write() without getting  
> -1/EWOULDBLOCK. Both of those are true when the socket is closed. I  
> guess I just don't understand the importance of making finer  
> distinctions than that before you actually try to do something.

My requirement basically came out of the way my application is currently
implemented. I get some weird I/O races because I can't properly detect
a socket closing (because I get socket readiness events from a seperate
piece of code to where I actually do the I/O). I can't actually remember
the reasoning right now, and I don't have my notes on hand, so I can't
be more specific.

However, I've thought about my design after considering the above
explanation, and I think I've got a better way that gives me both the
abstraction I want and detects socket closure by watching for read()
failing. So I'm happy to retract this patch.

Thanks all for educating me :)

Rob.

-- 
Robert Norris                                       GPG: 1024D/FC18E6C2
Email+Jabber: rob@cataclysm.cx                Web: http://cataclysm.cx/

Mime
View raw message