summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2012-02-20 12:18:22 +0000
committerDaniel Stenberg <daniel@haxx.se>2012-02-21 22:50:46 +0100
commit2f1ad7d6e2192e64ca6a5187ecf44a80b0425389 (patch)
tree69f8565ca8c75b7afab587c6f68979359a207968
parent30c44edad3bb31341aa2992948e377848125f8b1 (diff)
downloadgnurl-2f1ad7d6e2192e64ca6a5187ecf44a80b0425389.tar.gz
gnurl-2f1ad7d6e2192e64ca6a5187ecf44a80b0425389.tar.bz2
gnurl-2f1ad7d6e2192e64ca6a5187ecf44a80b0425389.zip
smtp.c: Fixed an issue with writing postdata
Fixed a problem in smtp_done() when writing out the postdata as Curl_write() would periodically return zero bytes written.
-rw-r--r--lib/smtp.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index 3ee068692..b0b4d1aaa 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -1035,6 +1035,7 @@ static CURLcode smtp_state_rcpt_resp(struct connectdata *conn,
/* send DATA */
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "DATA");
+
if(result)
return result;
@@ -1392,9 +1393,6 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
struct smtp_conn *smtpc = &conn->proto.smtpc;
struct pingpong *pp = &smtpc->pp;
- /* TODO: make this work even when the socket is EWOULDBLOCK in this
- call! */
-
/* Send the end of block data */
result = Curl_write(conn,
conn->writesockfd, /* socket to send to */
@@ -1402,7 +1400,19 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
SMTP_EOB_LEN, /* buffer size */
&bytes_written); /* actually sent away */
- pp->response = Curl_tvnow(); /* timeout relative now */
+ if(result)
+ return result;
+
+ if(bytes_written != SMTP_EOB_LEN) {
+ /* The whole chunk was not sent so keep it around and adjust the
+ pingpong structure accordingly */
+ pp->sendthis = strdup(SMTP_EOB);
+ pp->sendsize = SMTP_EOB_LEN;
+ pp->sendleft = SMTP_EOB_LEN - bytes_written;
+ }
+ else
+ /* Successfully sent so adjust the response timeout relative to now */
+ pp->response = Curl_tvnow();
state(conn, SMTP_POSTDATA);