summaryrefslogtreecommitdiff
path: root/lib/sendf.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-09-22 23:12:00 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-09-22 23:12:00 +0000
commit391e8afd1f6695cb57738790676cfa4d57d54bcb (patch)
tree5752243fa1fbf088953fa101c0a542873f2050cb /lib/sendf.c
parenteff2c3a621c539713ecd641c020f06ac28a7ea1d (diff)
downloadcurl-391e8afd1f6695cb57738790676cfa4d57d54bcb.tar.gz
- Made the SOCKS code use the new Curl_read_plain() function to fix the bug
Markus Moeller reported: http://curl.haxx.se/mail/archive-2008-09/0016.html - recv() errors other than those equal to EAGAIN now cause proper CURLE_RECV_ERROR to get returned. This made test case 160 fail so I've now disabled it until we can figure out another way to exercise that logic.
Diffstat (limited to 'lib/sendf.c')
-rw-r--r--lib/sendf.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/lib/sendf.c b/lib/sendf.c
index 568e7b8cd..79d34de60 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -534,6 +534,30 @@ CURLcode Curl_client_write(struct connectdata *conn,
return CURLE_OK;
}
+CURLcode Curl_read_plain(curl_socket_t sockfd,
+ char *buf,
+ size_t bytesfromsocket,
+ ssize_t *n)
+{
+ ssize_t nread = sread(sockfd, buf, bytesfromsocket);
+
+ if(-1 == nread) {
+ int err = SOCKERRNO;
+#ifdef USE_WINSOCK
+ if(WSAEWOULDBLOCK == err)
+#else
+ if((EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err))
+#endif
+ return -1;
+ else
+ return CURLE_RECV_ERROR;
+ }
+
+ /* we only return number of bytes read when we return OK */
+ *n = nread;
+ return CURLE_OK;
+}
+
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
@@ -613,20 +637,13 @@ int Curl_read(struct connectdata *conn, /* connection data */
if(conn->sec_complete)
nread = Curl_sec_read(conn, sockfd, buffertofill,
bytesfromsocket);
- else
- nread = sread(sockfd, buffertofill, bytesfromsocket);
-
- if(-1 == nread) {
- int err = SOCKERRNO;
-#ifdef USE_WINSOCK
- if(WSAEWOULDBLOCK == err)
-#else
- if((EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err))
-#endif
- return -1;
+ else {
+ CURLcode ret = Curl_read_plain(sockfd, buffertofill, bytesfromsocket,
+ &nread);
+ if(ret)
+ return ret;
}
}
-
if(nread >= 0) {
if(pipelining) {
memcpy(buf, conn->master_buffer, nread);