From 01a475ea41265929951e6d14f6dd216671b63331 Mon Sep 17 00:00:00 2001 From: Alain Schneble Date: Mon, 7 Mar 2016 00:00:57 +0100 Subject: [PATCH] Solve async GnuTLS handshake issue on w32 * src/w32.c (sys_write): For non-blocking sockets, return immediately with EWOULDBLOCK. This ensures we do not temporarily turn the socket into blocking mode for the pfn_send call if the socket is not (yet) connected. It turned out that doing so causes arbitrary GnuTLS handshake failures on MS-Windows. (bug#22789) --- src/w32.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/w32.c b/src/w32.c index 998f696..ee8cf6c 100644 --- a/src/w32.c +++ b/src/w32.c @@ -8647,6 +8647,12 @@ sys_write (int fd, const void * buffer, unsigned int count) unsigned long nblock = 0; if (winsock_lib == NULL) emacs_abort (); + if ((fd_info[fd].flags & FILE_CONNECT) != 0) + { + errno = EWOULDBLOCK; + return -1; + } + /* TODO: implement select() properly so non-blocking I/O works. */ /* For now, make sure the write blocks. */ if (fd_info[fd].flags & FILE_NDELAY) -- 2.6.2.windows.1