[libsoup] Tell GnuTLS about interesting Winsock errors



commit e2b8b01418cf4515c7858e9b43916dd36316f026
Author: Tor Lillqvist <tml iki fi>
Date:   Thu Nov 5 22:10:21 2009 +0200

    Tell GnuTLS about interesting Winsock errors
    
    In the pull and push functions, if we get a Winsock error, tell GnuTLS
    about it. Treat WSAEWOULDBLOCK and WSAETIMEDOUT as EAGAIN and WSAEINTR
    as EINTR. This helps timeout-test run to finish.
    
    Approved in bug #600749.

 libsoup/soup-gnutls.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/soup-gnutls.c b/libsoup/soup-gnutls.c
index 821d8ab..c77f2b2 100644
--- a/libsoup/soup-gnutls.c
+++ b/libsoup/soup-gnutls.c
@@ -392,7 +392,17 @@ soup_gnutls_pull_func (gnutls_transport_ptr_t transport_data,
 
 	nread = recv (chan->sockfd, buf, buflen, 0);
 #ifdef G_OS_WIN32
-	chan->eagain = (nread == SOCKET_ERROR && WSAGetLastError () == WSAEWOULDBLOCK);
+	{
+		int wsa_errno = WSAGetLastError ();
+		chan->eagain = (nread == SOCKET_ERROR && (wsa_errno == WSAEWOULDBLOCK ||
+							  wsa_errno == WSAETIMEDOUT));
+		if (nread == SOCKET_ERROR)
+			gnutls_transport_set_errno (chan->session,
+						    ((wsa_errno == WSAEWOULDBLOCK ||
+						      wsa_errno == WSAETIMEDOUT) ? EAGAIN :
+						     (wsa_errno == WSAEINTR ? EINTR :
+						      EIO)));
+	}
 #else
 	chan->eagain = (nread == -1 && errno == EAGAIN);
 #endif
@@ -408,7 +418,15 @@ soup_gnutls_push_func (gnutls_transport_ptr_t transport_data,
 
 	nwrote = send (chan->sockfd, buf, buflen, 0);
 #ifdef G_OS_WIN32
-	chan->eagain = (nwrote == SOCKET_ERROR && WSAGetLastError () == WSAEWOULDBLOCK);
+	{
+		int wsa_errno = WSAGetLastError ();
+		chan->eagain = (nwrote == SOCKET_ERROR && wsa_errno == WSAEWOULDBLOCK);
+		if (nwrote == SOCKET_ERROR)
+			gnutls_transport_set_errno (chan->session,
+						    (wsa_errno == WSAEWOULDBLOCK ? EAGAIN :
+						     (wsa_errno == WSAEINTR ? EINTR :
+						      EIO)));
+	}
 #else
 	chan->eagain = (nwrote == -1 && errno == EAGAIN);
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]