From b6dba9f5dda70e2a038b7aad394fbace7ccbeb82 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 16 Jan 2002 14:46:00 +0000 Subject: 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. --- lib/ftp.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'lib/ftp.c') 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; } /*********************************************************************** -- cgit v1.2.3