From 69406f0be7ba15a14683ef98eba4b1fe7e7f14c8 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Tue, 14 Feb 2012 14:21:21 +0000 Subject: [PATCH] SMTP: Fixed error when using CURLOPT_CONNECT_ONLY Fixed incorrect behavior in smtp_done() which would cause the end of block data to be sent to the SMTP server if libcurl was operating in connect only mode. This would cause the server to return an error as data would not be expected which in turn caused libcurl to return CURLE_RECV_ERROR. --- lib/smtp.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/smtp.c b/lib/smtp.c index 553c697d0..95e71d75a 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -1364,25 +1364,25 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status, conn->bits.close = TRUE; /* marked for closure */ result = status; /* use the already set error code */ } - else + else if(!data->set.connect_only) { + 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! */ - /* write to socket (send away data) */ + /* Send the end of block data */ result = Curl_write(conn, conn->writesockfd, /* socket to send to */ SMTP_EOB, /* buffer pointer */ SMTP_EOB_LEN, /* buffer size */ &bytes_written); /* actually sent away */ - - if(status == CURLE_OK) { - struct smtp_conn *smtpc = &conn->proto.smtpc; - struct pingpong *pp = &smtpc->pp; pp->response = Curl_tvnow(); /* timeout relative now */ state(conn, SMTP_POSTDATA); - /* run the state-machine + + /* Run the state-machine TODO: when the multi interface is used, this _really_ should be using the smtp_multi_statemach function but we have no general support for @@ -1392,7 +1392,7 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status, result = smtp_easy_statemach(conn); } - /* clear these for next connection */ + /* Clear the transfer mode for the next connection */ smtp->transfer = FTPTRANSFER_BODY; return result;