summaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-07-29 16:35:09 +0200
committerDaniel Stenberg <daniel@haxx.se>2017-07-29 16:35:09 +0200
commit0bd2d077afbac413d52980a943cf4ac241956a7a (patch)
treed0bb92cbcc2fe85c2fb1f9e13df2b76be28cf8f9 /lib/url.c
parent171f8ded26d2845ef358c62f6e95ec34468349ae (diff)
downloadcurl-0bd2d077afbac413d52980a943cf4ac241956a7a.tar.gz
now: update 'now' as part of the easy handle instead of local variablesbagder/now-remade
... as the mix of both passing in current time and figuring it out locally sometimes made "now" move in time in unexpected ways. Curl_timeleft() got an updated prototype. The old defines for Curl_tvnow() and Curl_tvdiff() are now removed. Renamed the conn->new member to setup_time and fixed its use somewhat. Moved the 'now' field from the SingleRequest struct within the easy handle to the struct UrlState.
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/url.c b/lib/url.c
index 2e7934375..9b8f3aff2 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -3279,7 +3279,7 @@ Curl_oldest_idle_connection(struct Curl_easy *data)
struct connectdata *conn_candidate = NULL;
struct connectbundle *bundle;
- now = Curl_tvnow();
+ now = curlx_tvnow();
Curl_hash_start_iterate(&bc->hash, &iter);
@@ -3295,7 +3295,7 @@ Curl_oldest_idle_connection(struct Curl_easy *data)
if(!conn->inuse) {
/* Set higher score for the age passed since the connection was used */
- score = Curl_tvdiff(now, conn->now);
+ score = curlx_tvdiff(now, conn->setup_time);
if(score > highscore) {
highscore = score;
@@ -3344,7 +3344,7 @@ find_oldest_idle_connection_in_bundle(struct Curl_easy *data,
(void)data;
- now = Curl_tvnow();
+ now = curlx_tvnow();
curr = bundle->conn_list.head;
while(curr) {
@@ -3352,7 +3352,7 @@ find_oldest_idle_connection_in_bundle(struct Curl_easy *data,
if(!conn->inuse) {
/* Set higher score for the age passed since the connection was used */
- score = Curl_tvdiff(now, conn->now);
+ score = curlx_tvdiff(now, conn->setup_time);
if(score > highscore) {
highscore = score;
@@ -3426,8 +3426,8 @@ static int call_disconnect_if_dead(struct connectdata *conn,
*/
static void prune_dead_connections(struct Curl_easy *data)
{
- struct curltime now = Curl_tvnow();
- time_t elapsed = Curl_tvdiff(now, data->state.conn_cache->last_cleanup);
+ struct curltime now = curlx_tvnow();
+ time_t elapsed = curlx_tvdiff(now, data->state.conn_cache->last_cleanup);
if(elapsed >= 1000L) {
Curl_conncache_foreach(data->state.conn_cache, data,
@@ -4194,7 +4194,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
connclose(conn, "Default to force-close");
/* Store creation time to help future close decision making */
- conn->created = Curl_tvnow();
+ conn->created = curlx_tvnow();
conn->data = data; /* Setup the association between this connection
and the Curl_easy */
@@ -6116,7 +6116,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
bool *async)
{
CURLcode result=CURLE_OK;
- time_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ time_t timeout_ms = Curl_timeleft(data, TRUE);
/*************************************************************
* Resolve the name of the server or proxy
@@ -6916,9 +6916,9 @@ CURLcode Curl_setup_conn(struct connectdata *conn,
data->state.crlf_conversions = 0; /* reset CRLF conversion counter */
#endif /* CURL_DO_LINEEND_CONV */
- /* set start time here for timeout purposes in the connect procedure, it
- is later set again for the progress meter purpose */
- conn->now = Curl_tvnow();
+ /* set setup time here for timeout purposes in the connect procedure, it is
+ later set again for the progress meter purpose */
+ conn->setup_time = curlx_tvnow();
if(CURL_SOCKET_BAD == conn->sock[FIRSTSOCKET]) {
conn->bits.tcpconnect[FIRSTSOCKET] = FALSE;
@@ -6935,8 +6935,8 @@ CURLcode Curl_setup_conn(struct connectdata *conn,
Curl_verboseconnect(conn);
}
- conn->now = Curl_tvnow(); /* time this *after* the connect is done, we
- set this here perhaps a second time */
+ conn->setup_time = curlx_tvnow(); /* sets this *after* the connect is done,
+ perhaps a second time */
#ifdef __EMX__
/*
@@ -7026,12 +7026,9 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn)
HTTP. */
data->set.httpreq = HTTPREQ_GET;
- k->start = Curl_tvnow(); /* start time */
- k->now = k->start; /* current time is now */
+ k->start = curlx_tvnow(); /* start time */
k->header = TRUE; /* assume header */
-
k->bytecount = 0;
-
k->buf = data->state.buffer;
k->hbufp = data->state.headerbuff;
k->ignorebody=FALSE;