Commit 4dee50b9 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

timeval: struct curltime is a struct timeval replacement

... to make all libcurl internals able to use the same data types for
the struct members. The timeval struct differs subtly on several
platforms so it makes it cumbersome to use everywhere.

Ref: #1652
Closes #1693
parent 7551e55d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -355,7 +355,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
  CURLcode result = CURLE_OK;
  struct Curl_easy *data = conn->data;
  long timeout;
  struct timeval now = Curl_tvnow();
  struct curltime now = Curl_tvnow();
  struct Curl_dns_entry *temp_entry;

  if(entry)
@@ -400,7 +400,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
    if(Curl_pgrsUpdate(conn))
      result = CURLE_ABORTED_BY_CALLBACK;
    else {
      struct timeval now2 = Curl_tvnow();
      struct curltime now2 = Curl_tvnow();
      time_t timediff = Curl_tvdiff(now2, now); /* spent time */
      if(timediff <= 0)
        timeout -= 1; /* always deduct at least 1 */
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ struct conncache {
  struct curl_hash hash;
  size_t num_connections;
  long next_connection_id;
  struct timeval last_cleanup;
  struct curltime last_cleanup;
};

#define BUNDLE_NO_MULTIUSE -1
+4 −4
Original line number Diff line number Diff line
@@ -180,12 +180,12 @@ singleipconnect(struct connectdata *conn,
 * @unittest: 1303
 */
time_t Curl_timeleft(struct Curl_easy *data,
                     struct timeval *nowp,
                     struct curltime *nowp,
                     bool duringconnect)
{
  int timeout_set = 0;
  time_t timeout_ms = duringconnect?DEFAULT_CONNECT_TIMEOUT:0;
  struct timeval now;
  struct curltime now;

  /* if a timeout is set, use the most restrictive one */

@@ -723,7 +723,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
  CURLcode result = CURLE_OK;
  time_t allow;
  int error = 0;
  struct timeval now;
  struct curltime now;
  int rc;
  int i;

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

  time_t timeout_ms = Curl_timeleft(data, &before, TRUE);
+2 −2
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -36,7 +36,7 @@ CURLcode Curl_connecthost(struct connectdata *conn,
/* generic function that returns how much time there's left to run, according
   to the timeouts set */
time_t Curl_timeleft(struct Curl_easy *data,
                     struct timeval *nowp,
                     struct curltime *nowp,
                     bool duringconnect);

#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */
+4 −4
Original line number Diff line number Diff line
@@ -572,8 +572,8 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
    int numfds=0;
    int pollrc;
    int i;
    struct timeval before;
    struct timeval after;
    struct curltime before;
    struct curltime after;

    /* populate the fds[] array */
    for(m = ev->list, f=&fds[0]; m; m = m->next) {
@@ -670,7 +670,7 @@ static CURLcode easy_transfer(struct Curl_multi *multi)
  bool done = FALSE;
  CURLMcode mcode = CURLM_OK;
  CURLcode result = CURLE_OK;
  struct timeval before;
  struct curltime before;
  int without_fds = 0;  /* count number of consecutive returns from
                           curl_multi_wait() without any filedescriptors */

@@ -683,7 +683,7 @@ static CURLcode easy_transfer(struct Curl_multi *multi)

    if(!mcode) {
      if(!rc) {
        struct timeval after = curlx_tvnow();
        struct curltime after = curlx_tvnow();

        /* If it returns without any filedescriptor instantly, we need to
           avoid busy-looping during periods where it has nothing particular
Loading