]> code.delx.au - gnu-emacs/commit
Support non-blocking connect on MS-Windows (Bug#20207)
authorEli Zaretskii <eliz@gnu.org>
Fri, 27 Mar 2015 09:44:31 +0000 (12:44 +0300)
committerEli Zaretskii <eliz@gnu.org>
Fri, 27 Mar 2015 09:44:31 +0000 (12:44 +0300)
commitd133cf839421462280ac0bfd9bd84c591f0e0249
treed964223f8da827058aece69ed66ca25ba82ebbf4
parent792d44b3c31d2a682607ab8b79ae7d26b7402f41
Support non-blocking connect on MS-Windows  (Bug#20207)

 Based on ideas from Kim F. Storm <storm@cua.dk>, see
 http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg00873.html.

 src/w32proc.c (reader_thread): If the FILE_CONNECT flag is set, call
 '_sys_wait_connect'.  If it returns STATUS_CONNECT_FAILED, exit
 the thread with code 2.
 (sys_select): Support 'wfds' in addition to 'rfds'.  If a
 descriptor in 'wfds' has its bit set, but the corresponding
 fd_info member doesn't have its FILE_CONNECT flag set, ignore the
 descriptor.  Otherwise, acknowledge a successful non-blocking
 connect by resetting the FILE_CONNECT flag and setting cp->status
 to STATUS_READ_ACKNOWLEDGED.
 src/w32.h (STATUS_CONNECT_FAILED): New enumeration value.
 (struct _child_process): New member 'errcode'.
 (FILE_CONNECT): New flag.
 (_sys_wait_connect): Add prototype.
 src/w32.c (pfn_WSAEnumNetworkEvents): New function pointer.
 (init_winsock): Load WSAEnumNetworkEvents from winsock DLL.
 (set_errno): Map WSAEWOULDBLOCK and WSAENOTCONN.
 (sys_connect): Support non-blocking 'connect' calls by setting the
 FILE_CONNECT flag in the fd_info member and returning EINPROGRESS.
 (_sys_read_ahead): Add debug message if this function is called
 for a descriptor that waits for a non-blocking connect to complete.
 (_sys_wait_connect): New function.
 (sys_read): Support STATUS_CONNECT_FAILED.  Return the error code
 recorded by _sys_wait_connect when the non-blocking connect
 failed.  Don't call WSAGetLastError before a call to set_errno had
 a chance to use its value, since WSAGetLastError clears the last
 error.

 nt/inc/ms-w32.h (BROKEN_NON_BLOCKING_CONNECT): Don't define.
nt/ChangeLog
nt/inc/ms-w32.h
src/ChangeLog
src/w32.c
src/w32.h
src/w32proc.c