summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-01-16 14:46:00 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-01-16 14:46:00 +0000
commitb6dba9f5dda70e2a038b7aad394fbace7ccbeb82 (patch)
treeca04402623e74317834945dc1b18b8cbd5c43b24
parent6e9d1617c665dd49b2e46979e59b76363b89ecf3 (diff)
downloadgnurl-b6dba9f5dda70e2a038b7aad394fbace7ccbeb82.tar.gz
gnurl-b6dba9f5dda70e2a038b7aad394fbace7ccbeb82.tar.bz2
gnurl-b6dba9f5dda70e2a038b7aad394fbace7ccbeb82.zip
Somewhat ugly fix to deal with non-blocking sockets. We just loop and try
again. THIS IS NOT A NICE FIX. We should/must make a select() then and only retry when we can write to the socket again.
-rw-r--r--lib/ftp.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 2def61f08..0ac280f61 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -2058,9 +2058,11 @@ CURLcode Curl_ftp(struct connectdata *conn)
CURLcode Curl_ftpsendf(struct connectdata *conn,
const char *fmt, ...)
{
- size_t bytes_written;
+ ssize_t bytes_written;
char s[256];
- size_t write_len;
+ ssize_t write_len;
+ char *sptr=s;
+ CURLcode res = CURLE_OK;
va_list ap;
va_start(ap, fmt);
@@ -2074,9 +2076,23 @@ CURLcode Curl_ftpsendf(struct connectdata *conn,
bytes_written=0;
write_len = strlen(s);
- Curl_write(conn, conn->firstsocket, s, write_len, &bytes_written);
- return (bytes_written==write_len)?CURLE_OK:CURLE_WRITE_ERROR;
+ do {
+ res = Curl_write(conn, conn->firstsocket, sptr, write_len,
+ &bytes_written);
+
+ if(CURLE_OK != res)
+ break;
+
+ if(bytes_written != write_len) {
+ write_len -= bytes_written;
+ sptr += bytes_written;
+ }
+ else
+ break;
+ } while(1);
+
+ return res;
}
/***********************************************************************