aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ftp.c1
-rw-r--r--lib/pingpong.c33
-rw-r--r--lib/smtp.c6
3 files changed, 25 insertions, 15 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 85419009e..552ecf8ee 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -3071,6 +3071,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
long old_time = pp->response_time;
pp->response_time = 60*1000; /* give it only a minute for now */
+ pp->response = Curl_tvnow(); /* timeout relative now */
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
diff --git a/lib/pingpong.c b/lib/pingpong.c
index 6f27f5761..072e56207 100644
--- a/lib/pingpong.c
+++ b/lib/pingpong.c
@@ -50,23 +50,28 @@ long Curl_pp_state_timeout(struct pingpong *pp)
struct connectdata *conn = pp->conn;
struct SessionHandle *data=conn->data;
long timeout_ms; /* in milliseconds */
+ long timeout2_ms; /* in milliseconds */
+ long response_time= (data->set.server_response_timeout)?
+ data->set.server_response_timeout: pp->response_time;
- if(data->set.server_response_timeout )
- /* if CURLOPT_SERVER_RESPONSE_TIMEOUT is set, use that to determine
- remaining time. Also, use pp->response because SERVER_RESPONSE_TIMEOUT
- is supposed to govern the response for any given server response, not
- for the time from connect to the given server response. */
- timeout_ms = data->set.server_response_timeout - /* timeout time */
- Curl_tvdiff(Curl_tvnow(), pp->response); /* spent time */
- else if(data->set.timeout)
+ /* if CURLOPT_SERVER_RESPONSE_TIMEOUT is set, use that to determine
+ remaining time, or use pp->response because SERVER_RESPONSE_TIMEOUT is
+ supposed to govern the response for any given server response, not for
+ the time from connect to the given server response. */
+
+ /* Without a requested timeout, we only wait 'response_time' seconds for the
+ full response to arrive before we bail out */
+ timeout_ms = response_time -
+ Curl_tvdiff(Curl_tvnow(), pp->response); /* spent time */
+
+ if(data->set.timeout) {
/* if timeout is requested, find out how much remaining time we have */
- timeout_ms = data->set.timeout - /* timeout time */
+ timeout2_ms = data->set.timeout - /* timeout time */
Curl_tvdiff(Curl_tvnow(), conn->now); /* spent time */
- else
- /* Without a requested timeout, we only wait 'response_time' seconds for
- the full response to arrive before we bail out */
- timeout_ms = pp->response_time -
- Curl_tvdiff(Curl_tvnow(), pp->response); /* spent time */
+
+ /* pick the lowest number */
+ timeout_ms = CURLMIN(timeout_ms, timeout2_ms);
+ }
return timeout_ms;
}
diff --git a/lib/smtp.c b/lib/smtp.c
index 2587934cf..f7757f057 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -637,7 +637,7 @@ static CURLcode smtp_init(struct connectdata *conn)
* a part of the easy interface, it will always be TRUE.
*/
static CURLcode smtp_connect(struct connectdata *conn,
- bool *done) /* see description above */
+ bool *done) /* see description above */
{
CURLcode result;
struct smtp_conn *smtpc = &conn->proto.smtpc;
@@ -784,6 +784,10 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
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