[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9295d0a: Fix TLS connections on MS-Windows
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master 9295d0a: Fix TLS connections on MS-Windows |
Date: |
Sun, 28 Feb 2016 16:46:25 +0000 |
branch: master
commit 9295d0a8c2078e5b85bc81b1f020cc73793767df
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Fix TLS connections on MS-Windows
* src/w32.c (sys_write): If 'send' returns with WSAENOTCONN, and
this is a non-blocking socket whose connection is in progress, set
errno to EWOULDBLOCK, as expected by GnuTLS and other callers.
Avoid overwriting the errno value from 'send' by 'ioctlsocket'.
Suggested by Alain Schneble <address@hidden>. (Bug#22789)
---
src/w32.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/w32.c b/src/w32.c
index d298f47..998f696 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -8654,6 +8654,19 @@ sys_write (int fd, const void * buffer, unsigned int
count)
nchars = pfn_send (SOCK_HANDLE (fd), buffer, count, 0);
+ if (nchars == SOCKET_ERROR)
+ {
+ set_errno ();
+ /* If this is a non-blocking socket whose connection is in
+ progress, return the proper error code to the caller;
+ ENOTCONN is not what they expect . */
+ if (errno == ENOTCONN && (fd_info[fd].flags & FILE_CONNECT) != 0)
+ errno = EWOULDBLOCK;
+ else
+ DebPrint (("sys_write.send failed with error %d on socket %ld\n",
+ pfn_WSAGetLastError (), SOCK_HANDLE (fd)));
+ }
+
/* Set the socket back to non-blocking if it was before,
for other operations that support it. */
if (fd_info[fd].flags & FILE_NDELAY)
@@ -8661,13 +8674,6 @@ sys_write (int fd, const void * buffer, unsigned int
count)
nblock = 1;
pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock);
}
-
- if (nchars == SOCKET_ERROR)
- {
- DebPrint (("sys_write.send failed with error %d on socket %ld\n",
- pfn_WSAGetLastError (), SOCK_HANDLE (fd)));
- set_errno ();
- }
}
else
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 9295d0a: Fix TLS connections on MS-Windows,
Eli Zaretskii <=