lkml.org 
[lkml]   [2003]   [Jun]   [8]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateSun, 08 Jun 2003 00:15:52 -0400
FromChris Friesen <>
SubjectRe: select for UNIX sockets?
David Schwartz wrote:

> 	You are doing something wrong. You are using 'select' along with blocking
> I/O operations. You can't make bricks without clay. If you don't want to
> block, you must use non-blocking socket operations. End of story.

That's funny, I was under the impression that the whole point of using select() 
was to enable the use of blocking I/O.  If you are on a uniprocessor system, in 
a single thread, and select() says that a socket is writeable, then I had darn 
well better be able to write to that socket!

Sure, this gets more complicated when multiprocessing or multithreading, but the 
test program does neither of these.

> 	Just because 'select' indicates a write hit, you are not assured that some
> particular write at a later time will not block. Past performance does not
> guarantee future results.


Think about the whole reason for select()'s existance. If a single-threaded app 
calls select() and is told a socket is writeable, then a write to that socket 
should either immediately succeed or immediately fail (if the other socket 
disappeared in between the calls, for instance).

Now granted I use non-blocking I/O out of paranoia, but even there if select() 
says it is writeable and the send call returns EAGAIN then we get into a nice 
little infinite loop.

select() should be reliable.


Chris


-- 
Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:36    [from the cache]
©2003-2008