diff options
author | Simon Josefsson <simon@josefsson.org> | 2006-11-07 10:23:23 +0000 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2006-11-07 10:23:23 +0000 |
commit | 76cd0edbda890dcc21cb3c989c4ca158a8ec9d6c (patch) | |
tree | d3b449764d04eb8c332ac95b13b34a0db60516da | |
parent | 0954019947a965e1da2a474f85a1d841100bdca8 (diff) | |
download | gnutls-76cd0edbda890dcc21cb3c989c4ca158a8ec9d6c.tar.gz |
Convert to EINTR/EAGAIN errno under Windows, using WSAGetLastError().
-rw-r--r-- | lib/gnutls_buffers.c | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c index 1b5a2f8f9d..f77308b4fe 100644 --- a/lib/gnutls_buffers.c +++ b/lib/gnutls_buffers.c @@ -319,8 +319,31 @@ _gnutls_read (gnutls_session_t session, void *iptr, session->internals.errnum = 0; if (session->internals._gnutls_pull_func == NULL) - i = recv (GNUTLS_POINTER_TO_INT(fd), &ptr[sizeOfPtr - left], - left, flags); + { + i = recv (GNUTLS_POINTER_TO_INT(fd), &ptr[sizeOfPtr - left], + left, flags); +#if HAVE_WINSOCK + if (i < 0) + { + int tmperr = WSAGetLastError(); + switch (tmperr) + { + case WSAEWOULDBLOCK: + errno = EAGAIN; + break; + + case WSAEINTR: + errno = EINTR; + break; + + default: + errno = EIO; + break; + } + WSASetLastError(tmperr); + } +#endif + } else i = session->internals._gnutls_pull_func (fd, &ptr[sizeOfPtr - @@ -761,7 +784,29 @@ _gnutls_io_write_buffered (gnutls_session_t session, session->internals.errnum = 0; if (session->internals._gnutls_push_func == NULL) - i = send (GNUTLS_POINTER_TO_INT(fd), &ptr[n - left], left, 0); + { + i = send (GNUTLS_POINTER_TO_INT(fd), &ptr[n - left], left, 0); +#if HAVE_WINSOCK + if (i < 0) + { + int tmperr = WSAGetLastError(); + switch (tmperr) + { + case WSAEWOULDBLOCK: + errno = EAGAIN; + break; + + case WSAEINTR: + errno = EINTR; + break; + + default: + errno = EIO; + break; + } + WSASetLastError(tmperr); + } +#endif else i = session->internals._gnutls_push_func (fd, &ptr[n - left], left); |