diff options
| author | Eli Zaretskii | 2016-02-28 18:44:50 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-02-28 18:44:50 +0200 |
| commit | 9295d0a8c2078e5b85bc81b1f020cc73793767df (patch) | |
| tree | e6fa5e45bb97e6d9312fff80fd42f9e059897236 /src | |
| parent | cd6067965761ccf31c48a106596b5187e85120e1 (diff) | |
| download | emacs-9295d0a8c2078e5b85bc81b1f020cc73793767df.tar.gz emacs-9295d0a8c2078e5b85bc81b1f020cc73793767df.zip | |
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 <a.s@realize.ch>. (Bug#22789)
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 20 |
1 files changed, 13 insertions, 7 deletions
| @@ -8654,6 +8654,19 @@ sys_write (int fd, const void * buffer, unsigned int count) | |||
| 8654 | 8654 | ||
| 8655 | nchars = pfn_send (SOCK_HANDLE (fd), buffer, count, 0); | 8655 | nchars = pfn_send (SOCK_HANDLE (fd), buffer, count, 0); |
| 8656 | 8656 | ||
| 8657 | if (nchars == SOCKET_ERROR) | ||
| 8658 | { | ||
| 8659 | set_errno (); | ||
| 8660 | /* If this is a non-blocking socket whose connection is in | ||
| 8661 | progress, return the proper error code to the caller; | ||
| 8662 | ENOTCONN is not what they expect . */ | ||
| 8663 | if (errno == ENOTCONN && (fd_info[fd].flags & FILE_CONNECT) != 0) | ||
| 8664 | errno = EWOULDBLOCK; | ||
| 8665 | else | ||
| 8666 | DebPrint (("sys_write.send failed with error %d on socket %ld\n", | ||
| 8667 | pfn_WSAGetLastError (), SOCK_HANDLE (fd))); | ||
| 8668 | } | ||
| 8669 | |||
| 8657 | /* Set the socket back to non-blocking if it was before, | 8670 | /* Set the socket back to non-blocking if it was before, |
| 8658 | for other operations that support it. */ | 8671 | for other operations that support it. */ |
| 8659 | if (fd_info[fd].flags & FILE_NDELAY) | 8672 | if (fd_info[fd].flags & FILE_NDELAY) |
| @@ -8661,13 +8674,6 @@ sys_write (int fd, const void * buffer, unsigned int count) | |||
| 8661 | nblock = 1; | 8674 | nblock = 1; |
| 8662 | pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock); | 8675 | pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock); |
| 8663 | } | 8676 | } |
| 8664 | |||
| 8665 | if (nchars == SOCKET_ERROR) | ||
| 8666 | { | ||
| 8667 | DebPrint (("sys_write.send failed with error %d on socket %ld\n", | ||
| 8668 | pfn_WSAGetLastError (), SOCK_HANDLE (fd))); | ||
| 8669 | set_errno (); | ||
| 8670 | } | ||
| 8671 | } | 8677 | } |
| 8672 | else | 8678 | else |
| 8673 | { | 8679 | { |