aboutsummaryrefslogtreecommitdiff
path: root/lib/sendf.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-01-14 23:14:59 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-01-14 23:14:59 +0000
commit4931fbce49887f7d4022c39ea7d94c4294b5f479 (patch)
treede5a20a6d1624ad07fe7509e10900773160d711b /lib/sendf.c
parentfefc7ea6008c48cbc3c346da4da55169da8c3adc (diff)
Curl_read() now returns a negative return code if EWOULDBLOCK or similar
Diffstat (limited to 'lib/sendf.c')
-rw-r--r--lib/sendf.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/sendf.c b/lib/sendf.c
index 78581f585..afb6991d6 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -266,14 +266,18 @@ CURLcode Curl_client_write(struct SessionHandle *data,
return CURLE_OK;
}
-
/*
* Internal read-from-socket function. This is meant to deal with plain
* sockets, SSL sockets and kerberos sockets.
+ *
+ * If the read would block (EWOULDBLOCK) we return -1. Otherwise we return
+ * a regular CURLcode value.
*/
-CURLcode Curl_read(struct connectdata *conn, int sockfd,
- char *buf, size_t buffersize,
- ssize_t *n)
+int Curl_read(struct connectdata *conn,
+ int sockfd,
+ char *buf,
+ size_t buffersize,
+ ssize_t *n)
{
ssize_t nread;
@@ -300,7 +304,9 @@ CURLcode Curl_read(struct connectdata *conn, int sockfd,
/* if there's data pending, then we re-invoke SSL_read() */
break;
}
- } while(loop && SSL_pending(conn->ssl.handle));
+ } while(0);
+ if(loop && SSL_pending(conn->ssl.handle))
+ return -1; /* basicly EWOULDBLOCK */
}
else {
#endif
@@ -310,6 +316,16 @@ CURLcode Curl_read(struct connectdata *conn, int sockfd,
else
#endif
nread = sread (sockfd, buf, buffersize);
+
+ if(-1 == nread) {
+#ifdef WIN32
+ if(EWOULDBLOCK == GetLastError())
+#else
+ if(EWOULDBLOCK == errno)
+#endif
+ return -1;
+ }
+
#ifdef USE_SSLEAY
}
#endif /* USE_SSLEAY */