Commit 5d543fe9 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

time: rename Curl_tvnow to Curl_now

... since the 'tv' stood for timeval and this function does not return a
timeval struct anymore.

Also, cleaned up the Curl_timediff*() functions to avoid typecasts and
clean up the descriptive comments.

Closes #2011
parent 1d72b5b8
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -355,7 +355,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
  CURLcode result = CURLE_OK;
  CURLcode result = CURLE_OK;
  struct Curl_easy *data = conn->data;
  struct Curl_easy *data = conn->data;
  long timeout;
  long timeout;
  struct curltime now = Curl_tvnow();
  struct curltime now = Curl_now();
  struct Curl_dns_entry *temp_entry;
  struct Curl_dns_entry *temp_entry;


  if(entry)
  if(entry)
@@ -400,7 +400,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
    if(Curl_pgrsUpdate(conn))
    if(Curl_pgrsUpdate(conn))
      result = CURLE_ABORTED_BY_CALLBACK;
      result = CURLE_ABORTED_BY_CALLBACK;
    else {
    else {
      struct curltime now2 = Curl_tvnow();
      struct curltime now2 = Curl_now();
      timediff_t timediff = Curl_timediff(now2, now); /* spent time */
      timediff_t timediff = Curl_timediff(now2, now); /* spent time */
      if(timediff <= 0)
      if(timediff <= 0)
        timeout -= 1; /* always deduct at least 1 */
        timeout -= 1; /* always deduct at least 1 */
+1 −1
Original line number Original line Diff line number Diff line
@@ -535,7 +535,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
  }
  }
  else {
  else {
    /* poll for name lookup done with exponential backoff up to 250ms */
    /* poll for name lookup done with exponential backoff up to 250ms */
    timediff_t elapsed = Curl_timediff(Curl_tvnow(),
    timediff_t elapsed = Curl_timediff(Curl_now(),
                                       data->progress.t_startsingle);
                                       data->progress.t_startsingle);
    if(elapsed < 0)
    if(elapsed < 0)
      elapsed = 0;
      elapsed = 0;
+4 −4
Original line number Original line Diff line number Diff line
@@ -218,7 +218,7 @@ time_t Curl_timeleft(struct Curl_easy *data,
  }
  }


  if(!nowp) {
  if(!nowp) {
    now = Curl_tvnow();
    now = Curl_now();
    nowp = &now;
    nowp = &now;
  }
  }


@@ -737,7 +737,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
    return CURLE_OK;
    return CURLE_OK;
  }
  }


  now = Curl_tvnow();
  now = Curl_now();


  /* figure out how long time we have left to connect */
  /* figure out how long time we have left to connect */
  allow = Curl_timeleft(data, &now, TRUE);
  allow = Curl_timeleft(data, &now, TRUE);
@@ -1051,7 +1051,7 @@ static CURLcode singleipconnect(struct connectdata *conn,
  /* set socket non-blocking */
  /* set socket non-blocking */
  (void)curlx_nonblock(sockfd, TRUE);
  (void)curlx_nonblock(sockfd, TRUE);


  conn->connecttime = Curl_tvnow();
  conn->connecttime = Curl_now();
  if(conn->num_addr > 1)
  if(conn->num_addr > 1)
    Curl_expire(data, conn->timeoutms_per_addr, EXPIRE_DNS_PER_NAME);
    Curl_expire(data, conn->timeoutms_per_addr, EXPIRE_DNS_PER_NAME);


@@ -1145,7 +1145,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
                          const struct Curl_dns_entry *remotehost)
                          const struct Curl_dns_entry *remotehost)
{
{
  struct Curl_easy *data = conn->data;
  struct Curl_easy *data = conn->data;
  struct curltime before = Curl_tvnow();
  struct curltime before = Curl_now();
  CURLcode result = CURLE_COULDNT_CONNECT;
  CURLcode result = CURLE_COULDNT_CONNECT;


  time_t timeout_ms = Curl_timeleft(data, &before, TRUE);
  time_t timeout_ms = Curl_timeleft(data, &before, TRUE);
+4 −4
Original line number Original line Diff line number Diff line
@@ -586,12 +586,12 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
    }
    }


    /* get the time stamp to use to figure out how long poll takes */
    /* get the time stamp to use to figure out how long poll takes */
    before = Curl_tvnow();
    before = Curl_now();


    /* wait for activity or timeout */
    /* wait for activity or timeout */
    pollrc = Curl_poll(fds, numfds, (int)ev->ms);
    pollrc = Curl_poll(fds, numfds, (int)ev->ms);


    after = Curl_tvnow();
    after = Curl_now();


    ev->msbump = FALSE; /* reset here */
    ev->msbump = FALSE; /* reset here */


@@ -680,12 +680,12 @@ static CURLcode easy_transfer(struct Curl_multi *multi)
    int still_running = 0;
    int still_running = 0;
    int rc;
    int rc;


    before = Curl_tvnow();
    before = Curl_now();
    mcode = curl_multi_wait(multi, NULL, 0, 1000, &rc);
    mcode = curl_multi_wait(multi, NULL, 0, 1000, &rc);


    if(!mcode) {
    if(!mcode) {
      if(!rc) {
      if(!rc) {
        struct curltime after = Curl_tvnow();
        struct curltime after = Curl_now();


        /* If it returns without any filedescriptor instantly, we need to
        /* If it returns without any filedescriptor instantly, we need to
           avoid busy-looping during periods where it has nothing particular
           avoid busy-looping during periods where it has nothing particular
+2 −2
Original line number Original line Diff line number Diff line
@@ -404,7 +404,7 @@ static CURLcode file_upload(struct connectdata *conn)
    if(Curl_pgrsUpdate(conn))
    if(Curl_pgrsUpdate(conn))
      result = CURLE_ABORTED_BY_CALLBACK;
      result = CURLE_ABORTED_BY_CALLBACK;
    else
    else
      result = Curl_speedcheck(data, Curl_tvnow());
      result = Curl_speedcheck(data, Curl_now());
  }
  }
  if(!result && Curl_pgrsUpdate(conn))
  if(!result && Curl_pgrsUpdate(conn))
    result = CURLE_ABORTED_BY_CALLBACK;
    result = CURLE_ABORTED_BY_CALLBACK;
@@ -589,7 +589,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
    if(Curl_pgrsUpdate(conn))
    if(Curl_pgrsUpdate(conn))
      result = CURLE_ABORTED_BY_CALLBACK;
      result = CURLE_ABORTED_BY_CALLBACK;
    else
    else
      result = Curl_speedcheck(data, Curl_tvnow());
      result = Curl_speedcheck(data, Curl_now());
  }
  }
  if(Curl_pgrsUpdate(conn))
  if(Curl_pgrsUpdate(conn))
    result = CURLE_ABORTED_BY_CALLBACK;
    result = CURLE_ABORTED_BY_CALLBACK;
Loading