aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-03-02 13:26:23 +0000
committerDaniel Stenberg <daniel@haxx.se>2010-03-02 13:26:23 +0000
commit13ac29382f9087d410a96f7ca943b16d39a10afb (patch)
tree8f9e682189c858add5696fba067a7ac8abe6dda0 /lib
parent8719398d052b9b52a6f75b6b0e4ab5de13896a4e (diff)
- Made the pingpong timeout code properly deal with the response timeout AND
the global timeout if set. Also, as was reported in the bug report #2956437 by Ryan Chan, the time stamp to use as basis for the per command timeout was not set properly in the DONE phase for FTP (and not for SMTP) so I fixed that just now. This was a regression compared to 7.19.7 due to the conversion of FTP code over to the generic pingpong concepts. http://curl.haxx.se/bug/view.cgi?id=2956437
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