summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-01-16 14:47:00 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-01-16 14:47:00 +0000
commitcba9838e8fcfdd653a60f7b01edacdb3a31214a2 (patch)
treefc5ea69bb5e90e623285f8d72707fb9a638720a3
parentb6dba9f5dda70e2a038b7aad394fbace7ccbeb82 (diff)
downloadgnurl-cba9838e8fcfdd653a60f7b01edacdb3a31214a2.tar.gz
gnurl-cba9838e8fcfdd653a60f7b01edacdb3a31214a2.tar.bz2
gnurl-cba9838e8fcfdd653a60f7b01edacdb3a31214a2.zip
Somewhat ugly fix to deal with non-blocking sockets. We just loop and try
again. THIS IS NOT A NICE FIX.
-rw-r--r--lib/http.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/http.c b/lib/http.c
index 795a6f79c..42668b398 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -128,8 +128,10 @@ static
CURLcode add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in,
long *bytes_written)
{
- size_t amount;
- CURLcode result;
+ ssize_t amount;
+ CURLcode res;
+ char *ptr;
+ int size;
if(conn->data->set.verbose) {
fputs("> ", conn->data->set.err);
@@ -137,7 +139,25 @@ CURLcode add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in,
fwrite(in->buffer, in->size_used, 1, conn->data->set.err);
}
- result = Curl_write(conn, sockfd, in->buffer, in->size_used, &amount);
+ /* The looping below is required since we use non-blocking sockets, but due
+ to the circumstances we will just loop and try again and again etc */
+
+ ptr = in->buffer;
+ size = in->size_used;
+ do {
+ res = Curl_write(conn, sockfd, ptr, size, &amount);
+
+ if(CURLE_OK != res)
+ break;
+
+ if(amount != size) {
+ size += amount;
+ ptr += amount;
+ }
+ else
+ break;
+
+ } while(1);
if(in->buffer)
free(in->buffer);
@@ -145,7 +165,7 @@ CURLcode add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in,
*bytes_written = amount;
- return result;
+ return res;
}