PLEASE TEST: New implementation of blocking socket I/O

Corinna Vinschen vinschen@redhat.com
Mon Mar 29 20:01:00 GMT 2004


Hi,

I've just applied a change of blocking socket read/write.  The old
implementation using overlapped I/O was apparently racy, see 
http://cygwin.com/ml/cygwin/2004-03/msg01446.html  The problem is
the need to call CancelIo if a signal arrived.

The new implementation uses asynchronous I/O now.  You can see the core
of the new implementation in the wsock_event class in net.cc.
Basically an event object is created and the approriate network events
are selected for the event (wsock_event::prepare).  Then the implementation
differs, depending on being in a recv or send.  In case of recvfrom and
recvmsg, wsock_event::wait waits for a FD_CLOSE or FD_READ arriving.
Since FD_CLOSE can arrive before all data has been read in case of
asynchronous I/O, the close event sets a flag in fhandler_socket (2nd
argument to wsock_event::wait), so that all remaining recv calls are
executed w/o using async I/O.  Analyzing the sendto and sendmsg cases
is left as an exercise for the reader.  It's all pretty straightforward.

PLEASE give the new code a thorough test.  I checked operation with
ssh, scp, ftp and lynx so far but I'm of course not sure if I met
all border conditions.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.



More information about the Cygwin-developers mailing list