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
This commit is contained in:
Daniel Stenberg 2017-07-28 15:49:36 +02:00
parent 7551e55d66
commit 4dee50b9c8
29 changed files with 152 additions and 128 deletions

View File

@ -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 timeval now = Curl_tvnow(); struct curltime now = Curl_tvnow();
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 timeval now2 = Curl_tvnow(); struct curltime now2 = Curl_tvnow();
time_t timediff = Curl_tvdiff(now2, now); /* spent time */ time_t timediff = Curl_tvdiff(now2, now); /* spent time */
if(timediff <= 0) if(timediff <= 0)
timeout -= 1; /* always deduct at least 1 */ timeout -= 1; /* always deduct at least 1 */

View File

@ -27,7 +27,7 @@ struct conncache {
struct curl_hash hash; struct curl_hash hash;
size_t num_connections; size_t num_connections;
long next_connection_id; long next_connection_id;
struct timeval last_cleanup; struct curltime last_cleanup;
}; };
#define BUNDLE_NO_MULTIUSE -1 #define BUNDLE_NO_MULTIUSE -1

View File

@ -180,12 +180,12 @@ singleipconnect(struct connectdata *conn,
* @unittest: 1303 * @unittest: 1303
*/ */
time_t Curl_timeleft(struct Curl_easy *data, time_t Curl_timeleft(struct Curl_easy *data,
struct timeval *nowp, struct curltime *nowp,
bool duringconnect) bool duringconnect)
{ {
int timeout_set = 0; int timeout_set = 0;
time_t timeout_ms = duringconnect?DEFAULT_CONNECT_TIMEOUT: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 */ /* 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; CURLcode result = CURLE_OK;
time_t allow; time_t allow;
int error = 0; int error = 0;
struct timeval now; struct curltime now;
int rc; int rc;
int i; int i;
@ -1136,7 +1136,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 timeval before = Curl_tvnow(); struct curltime before = Curl_tvnow();
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);

View File

@ -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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * 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 /* generic function that returns how much time there's left to run, according
to the timeouts set */ to the timeouts set */
time_t Curl_timeleft(struct Curl_easy *data, time_t Curl_timeleft(struct Curl_easy *data,
struct timeval *nowp, struct curltime *nowp,
bool duringconnect); bool duringconnect);
#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */

View File

@ -572,8 +572,8 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
int numfds=0; int numfds=0;
int pollrc; int pollrc;
int i; int i;
struct timeval before; struct curltime before;
struct timeval after; struct curltime after;
/* populate the fds[] array */ /* populate the fds[] array */
for(m = ev->list, f=&fds[0]; m; m = m->next) { 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; bool done = FALSE;
CURLMcode mcode = CURLM_OK; CURLMcode mcode = CURLM_OK;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct timeval before; struct curltime before;
int without_fds = 0; /* count number of consecutive returns from int without_fds = 0; /* count number of consecutive returns from
curl_multi_wait() without any filedescriptors */ curl_multi_wait() without any filedescriptors */
@ -683,7 +683,7 @@ static CURLcode easy_transfer(struct Curl_multi *multi)
if(!mcode) { if(!mcode) {
if(!rc) { if(!rc) {
struct timeval after = curlx_tvnow(); struct curltime after = curlx_tvnow();
/* 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

View File

@ -336,7 +336,7 @@ static time_t ftp_timeleft_accept(struct Curl_easy *data)
{ {
time_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT; time_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
time_t other; time_t other;
struct timeval now; struct curltime now;
if(data->set.accepttimeout > 0) if(data->set.accepttimeout > 0)
timeout_ms = data->set.accepttimeout; timeout_ms = data->set.accepttimeout;

View File

@ -70,7 +70,7 @@ static void singlesocket(struct Curl_multi *multi,
struct Curl_easy *data); struct Curl_easy *data);
static int update_timer(struct Curl_multi *multi); static int update_timer(struct Curl_multi *multi);
static CURLMcode add_next_timeout(struct timeval now, static CURLMcode add_next_timeout(struct curltime now,
struct Curl_multi *multi, struct Curl_multi *multi,
struct Curl_easy *d); struct Curl_easy *d);
static CURLMcode multi_timeout(struct Curl_multi *multi, static CURLMcode multi_timeout(struct Curl_multi *multi,
@ -1301,7 +1301,7 @@ static CURLcode multi_do_more(struct connectdata *conn, int *complete)
} }
static CURLMcode multi_runsingle(struct Curl_multi *multi, static CURLMcode multi_runsingle(struct Curl_multi *multi,
struct timeval now, struct curltime now,
struct Curl_easy *data) struct Curl_easy *data)
{ {
struct Curl_message *msg = NULL; struct Curl_message *msg = NULL;
@ -2146,7 +2146,7 @@ CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles)
struct Curl_easy *data; struct Curl_easy *data;
CURLMcode returncode=CURLM_OK; CURLMcode returncode=CURLM_OK;
struct Curl_tree *t; struct Curl_tree *t;
struct timeval now = Curl_tvnow(); struct curltime now = Curl_tvnow();
if(!GOOD_MULTI_HANDLE(multi)) if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE; return CURLM_BAD_HANDLE;
@ -2496,11 +2496,11 @@ void Curl_multi_closed(struct connectdata *conn, curl_socket_t s)
* The splay tree only has each sessionhandle as a single node and the nearest * The splay tree only has each sessionhandle as a single node and the nearest
* timeout is used to sort it on. * timeout is used to sort it on.
*/ */
static CURLMcode add_next_timeout(struct timeval now, static CURLMcode add_next_timeout(struct curltime now,
struct Curl_multi *multi, struct Curl_multi *multi,
struct Curl_easy *d) struct Curl_easy *d)
{ {
struct timeval *tv = &d->state.expiretime; struct curltime *tv = &d->state.expiretime;
struct curl_llist *list = &d->state.timeoutlist; struct curl_llist *list = &d->state.timeoutlist;
struct curl_llist_element *e; struct curl_llist_element *e;
struct time_node *node = NULL; struct time_node *node = NULL;
@ -2551,7 +2551,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
CURLMcode result = CURLM_OK; CURLMcode result = CURLM_OK;
struct Curl_easy *data = NULL; struct Curl_easy *data = NULL;
struct Curl_tree *t; struct Curl_tree *t;
struct timeval now = Curl_tvnow(); struct curltime now = Curl_tvnow();
if(checkall) { if(checkall) {
/* *perform() deals with running_handles on its own */ /* *perform() deals with running_handles on its own */
@ -2777,11 +2777,11 @@ CURLMcode curl_multi_socket_all(struct Curl_multi *multi, int *running_handles)
static CURLMcode multi_timeout(struct Curl_multi *multi, static CURLMcode multi_timeout(struct Curl_multi *multi,
long *timeout_ms) long *timeout_ms)
{ {
static struct timeval tv_zero = {0, 0}; static struct curltime tv_zero = {0, 0};
if(multi->timetree) { if(multi->timetree) {
/* we have a tree of expire times */ /* we have a tree of expire times */
struct timeval now = Curl_tvnow(); struct curltime now = Curl_tvnow();
/* splay the lowest to the bottom */ /* splay the lowest to the bottom */
multi->timetree = Curl_splay(tv_zero, multi->timetree); multi->timetree = Curl_splay(tv_zero, multi->timetree);
@ -2833,7 +2833,7 @@ static int update_timer(struct Curl_multi *multi)
return -1; return -1;
} }
if(timeout_ms < 0) { if(timeout_ms < 0) {
static const struct timeval none={0, 0}; static const struct curltime none={0, 0};
if(Curl_splaycomparekeys(none, multi->timer_lastcall)) { if(Curl_splaycomparekeys(none, multi->timer_lastcall)) {
multi->timer_lastcall = none; multi->timer_lastcall = none;
/* there's no timeout now but there was one previously, tell the app to /* there's no timeout now but there was one previously, tell the app to
@ -2884,7 +2884,7 @@ multi_deltimeout(struct Curl_easy *data, expire_id eid)
*/ */
static CURLMcode static CURLMcode
multi_addtimeout(struct Curl_easy *data, multi_addtimeout(struct Curl_easy *data,
struct timeval *stamp, struct curltime *stamp,
expire_id eid) expire_id eid)
{ {
struct curl_llist_element *e; struct curl_llist_element *e;
@ -2932,9 +2932,9 @@ multi_addtimeout(struct Curl_easy *data,
void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id) void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id)
{ {
struct Curl_multi *multi = data->multi; struct Curl_multi *multi = data->multi;
struct timeval *nowp = &data->state.expiretime; struct curltime *nowp = &data->state.expiretime;
int rc; int rc;
struct timeval set; struct curltime set;
/* this is only interesting while there is still an associated multi struct /* this is only interesting while there is still an associated multi struct
remaining! */ remaining! */
@ -2944,8 +2944,8 @@ void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id)
DEBUGASSERT(id < EXPIRE_LAST); DEBUGASSERT(id < EXPIRE_LAST);
set = Curl_tvnow(); set = Curl_tvnow();
set.tv_sec += (long)(milli/1000); set.tv_sec += milli/1000;
set.tv_usec += (long)(milli%1000)*1000; set.tv_usec += (unsigned int)(milli%1000)*1000;
if(set.tv_usec >= 1000000) { if(set.tv_usec >= 1000000) {
set.tv_sec++; set.tv_sec++;
@ -3007,7 +3007,7 @@ void Curl_expire_done(struct Curl_easy *data, expire_id id)
void Curl_expire_clear(struct Curl_easy *data) void Curl_expire_clear(struct Curl_easy *data)
{ {
struct Curl_multi *multi = data->multi; struct Curl_multi *multi = data->multi;
struct timeval *nowp = &data->state.expiretime; struct curltime *nowp = &data->state.expiretime;
int rc; int rc;
/* this is only interesting while there is still an associated multi struct /* this is only interesting while there is still an associated multi struct

View File

@ -148,7 +148,7 @@ struct Curl_multi {
/* timer callback and user data pointer for the *socket() API */ /* timer callback and user data pointer for the *socket() API */
curl_multi_timer_callback timer_cb; curl_multi_timer_callback timer_cb;
void *timer_userp; void *timer_userp;
struct timeval timer_lastcall; /* the fixed time for the timeout for the struct curltime timer_lastcall; /* the fixed time for the timeout for the
previous callback */ previous callback */
}; };

View File

@ -58,7 +58,7 @@ struct pingpong {
server */ server */
size_t sendleft; /* number of bytes left to send from the sendthis buffer */ size_t sendleft; /* number of bytes left to send from the sendthis buffer */
size_t sendsize; /* total size of the sendthis buffer */ size_t sendsize; /* total size of the sendthis buffer */
struct timeval response; /* set to Curl_tvnow() when a command has been sent struct curltime response; /* set to Curl_tvnow() when a command has been sent
off, used to time-out response reading */ off, used to time-out response reading */
long response_time; /* When no timeout is given, this is the amount of long response_time; /* When no timeout is given, this is the amount of
milliseconds we await for a server response. */ milliseconds we await for a server response. */

View File

@ -166,7 +166,7 @@ void Curl_pgrsResetTimesSizes(struct Curl_easy *data)
*/ */
void Curl_pgrsTime(struct Curl_easy *data, timerid timer) void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
{ {
struct timeval now = Curl_tvnow(); struct curltime now = Curl_tvnow();
time_t *delta = NULL; time_t *delta = NULL;
switch(timer) { switch(timer) {
@ -260,8 +260,8 @@ void Curl_pgrsStartNow(struct Curl_easy *data)
long Curl_pgrsLimitWaitTime(curl_off_t cursize, long Curl_pgrsLimitWaitTime(curl_off_t cursize,
curl_off_t startsize, curl_off_t startsize,
curl_off_t limit, curl_off_t limit,
struct timeval start, struct curltime start,
struct timeval now) struct curltime now)
{ {
curl_off_t size = cursize - startsize; curl_off_t size = cursize - startsize;
time_t minimum; time_t minimum;
@ -287,7 +287,7 @@ long Curl_pgrsLimitWaitTime(curl_off_t cursize,
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size) void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
{ {
struct timeval now = Curl_tvnow(); struct curltime now = Curl_tvnow();
data->progress.downloaded = size; data->progress.downloaded = size;
@ -305,7 +305,7 @@ void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size) void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size)
{ {
struct timeval now = Curl_tvnow(); struct curltime now = Curl_tvnow();
data->progress.uploaded = size; data->progress.uploaded = size;
@ -351,7 +351,7 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
*/ */
int Curl_pgrsUpdate(struct connectdata *conn) int Curl_pgrsUpdate(struct connectdata *conn)
{ {
struct timeval now; struct curltime now;
int result; int result;
char max5[6][10]; char max5[6][10];
curl_off_t dlpercen=0; curl_off_t dlpercen=0;

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, 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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -52,8 +52,8 @@ void Curl_pgrsTime(struct Curl_easy *data, timerid timer);
long Curl_pgrsLimitWaitTime(curl_off_t cursize, long Curl_pgrsLimitWaitTime(curl_off_t cursize,
curl_off_t startsize, curl_off_t startsize,
curl_off_t limit, curl_off_t limit,
struct timeval start, struct curltime start,
struct timeval now); struct curltime now);
/* Don't show progress for sizes smaller than: */ /* Don't show progress for sizes smaller than: */
#define LEAST_SIZE_PROGRESS BUFSIZE #define LEAST_SIZE_PROGRESS BUFSIZE

View File

@ -86,7 +86,7 @@ static CURLcode randit(struct Curl_easy *data, unsigned int *rnd)
#endif #endif
if(!seeded) { if(!seeded) {
struct timeval now = curlx_tvnow(); struct curltime now = curlx_tvnow();
infof(data, "WARNING: Using weak random seed\n"); infof(data, "WARNING: Using weak random seed\n");
randseed += (unsigned int)now.tv_usec + (unsigned int)now.tv_sec; randseed += (unsigned int)now.tv_usec + (unsigned int)now.tv_sec;
randseed = randseed * 1103515245 + 12345; randseed = randseed * 1103515245 + 12345;

View File

@ -78,7 +78,7 @@ int Curl_wait_ms(int timeout_ms)
#ifndef HAVE_POLL_FINE #ifndef HAVE_POLL_FINE
struct timeval pending_tv; struct timeval pending_tv;
#endif #endif
struct timeval initial_tv; struct curltime initial_tv;
int pending_ms; int pending_ms;
int error; int error;
#endif #endif
@ -158,7 +158,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
fd_set fds_err; fd_set fds_err;
curl_socket_t maxfd; curl_socket_t maxfd;
#endif #endif
struct timeval initial_tv = {0, 0}; struct curltime initial_tv = {0, 0};
int pending_ms = 0; int pending_ms = 0;
int error; int error;
int r; int r;
@ -398,7 +398,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
fd_set fds_err; fd_set fds_err;
curl_socket_t maxfd; curl_socket_t maxfd;
#endif #endif
struct timeval initial_tv = {0, 0}; struct curltime initial_tv = {0, 0};
bool fds_none = TRUE; bool fds_none = TRUE;
unsigned int i; unsigned int i;
int pending_ms = 0; int pending_ms = 0;
@ -571,8 +571,8 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
* *
* Return values are the same as select's. * Return values are the same as select's.
*/ */
int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes, int tpf_select_libcurl(int maxfds, fd_set *reads, fd_set *writes,
fd_set* excepts, struct timeval* tv) fd_set *excepts, struct timeval *tv)
{ {
int rc; int rc;

View File

@ -30,14 +30,14 @@
void Curl_speedinit(struct Curl_easy *data) void Curl_speedinit(struct Curl_easy *data)
{ {
memset(&data->state.keeps_speed, 0, sizeof(struct timeval)); memset(&data->state.keeps_speed, 0, sizeof(struct curltime));
} }
/* /*
* @unittest: 1606 * @unittest: 1606
*/ */
CURLcode Curl_speedcheck(struct Curl_easy *data, CURLcode Curl_speedcheck(struct Curl_easy *data,
struct timeval now) struct curltime now)
{ {
if((data->progress.current_speed >= 0) && data->set.low_speed_time) { if((data->progress.current_speed >= 0) && data->set.low_speed_time) {
if(data->progress.current_speed < data->set.low_speed_limit) { if(data->progress.current_speed < data->set.low_speed_limit) {

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2010, 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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,6 +28,6 @@
void Curl_speedinit(struct Curl_easy *data); void Curl_speedinit(struct Curl_easy *data);
CURLcode Curl_speedcheck(struct Curl_easy *data, CURLcode Curl_speedcheck(struct Curl_easy *data,
struct timeval now); struct curltime now);
#endif /* HEADER_CURL_SPEEDCHECK_H */ #endif /* HEADER_CURL_SPEEDCHECK_H */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1997 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1997 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -37,7 +37,7 @@
* Splay using the key i (which may or may not be in the tree.) The starting * Splay using the key i (which may or may not be in the tree.) The starting
* root is t. * root is t.
*/ */
struct Curl_tree *Curl_splay(struct timeval i, struct Curl_tree *Curl_splay(struct curltime i,
struct Curl_tree *t) struct Curl_tree *t)
{ {
struct Curl_tree N, *l, *r, *y; struct Curl_tree N, *l, *r, *y;
@ -97,11 +97,13 @@ struct Curl_tree *Curl_splay(struct timeval i,
* *
* @unittest: 1309 * @unittest: 1309
*/ */
struct Curl_tree *Curl_splayinsert(struct timeval i, struct Curl_tree *Curl_splayinsert(struct curltime i,
struct Curl_tree *t, struct Curl_tree *t,
struct Curl_tree *node) struct Curl_tree *node)
{ {
static const struct timeval KEY_NOTUSED = {-1, -1}; /* will *NEVER* appear */ static const struct curltime KEY_NOTUSED = {
-1, -1
}; /* will *NEVER* appear */
if(node == NULL) if(node == NULL)
return t; return t;
@ -114,7 +116,7 @@ struct Curl_tree *Curl_splayinsert(struct timeval i,
to the end of this list. */ to the end of this list. */
node->key = KEY_NOTUSED; /* we set the key in the sub node to NOTUSED node->key = KEY_NOTUSED; /* we set the key in the sub node to NOTUSED
to quickly identify this node as a subnode */ to quickly identify this node as a subnode */
node->samen = t; node->samen = t;
node->samep = t->samep; node->samep = t->samep;
t->samep->samen = node; t->samep->samen = node;
@ -149,11 +151,11 @@ struct Curl_tree *Curl_splayinsert(struct timeval i,
/* Finds and deletes the best-fit node from the tree. Return a pointer to the /* Finds and deletes the best-fit node from the tree. Return a pointer to the
resulting tree. best-fit means the smallest node if it is not larger than resulting tree. best-fit means the smallest node if it is not larger than
the key */ the key */
struct Curl_tree *Curl_splaygetbest(struct timeval i, struct Curl_tree *Curl_splaygetbest(struct curltime i,
struct Curl_tree *t, struct Curl_tree *t,
struct Curl_tree **removed) struct Curl_tree **removed)
{ {
static struct timeval tv_zero = {0, 0}; static struct curltime tv_zero = {0, 0};
struct Curl_tree *x; struct Curl_tree *x;
if(!t) { if(!t) {
@ -209,7 +211,9 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
struct Curl_tree *removenode, struct Curl_tree *removenode,
struct Curl_tree **newroot) struct Curl_tree **newroot)
{ {
static const struct timeval KEY_NOTUSED = {-1, -1}; /* will *NEVER* appear */ static const struct curltime KEY_NOTUSED = {
-1, -1
}; /* will *NEVER* appear */
struct Curl_tree *x; struct Curl_tree *x;
if(!t || !removenode) if(!t || !removenode)

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1997 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1997 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -22,30 +22,31 @@
* *
***************************************************************************/ ***************************************************************************/
#include "curl_setup.h" #include "curl_setup.h"
#include "timeval.h"
struct Curl_tree { struct Curl_tree {
struct Curl_tree *smaller; /* smaller node */ struct Curl_tree *smaller; /* smaller node */
struct Curl_tree *larger; /* larger node */ struct Curl_tree *larger; /* larger node */
struct Curl_tree *samen; /* points to the next node with identical key */ struct Curl_tree *samen; /* points to the next node with identical key */
struct Curl_tree *samep; /* points to the prev node with identical key */ struct Curl_tree *samep; /* points to the prev node with identical key */
struct timeval key; /* this node's "sort" key */ struct curltime key; /* this node's "sort" key */
void *payload; /* data the splay code doesn't care about */ void *payload; /* data the splay code doesn't care about */
}; };
struct Curl_tree *Curl_splay(struct timeval i, struct Curl_tree *Curl_splay(struct curltime i,
struct Curl_tree *t); struct Curl_tree *t);
struct Curl_tree *Curl_splayinsert(struct timeval key, struct Curl_tree *Curl_splayinsert(struct curltime key,
struct Curl_tree *t, struct Curl_tree *t,
struct Curl_tree *newnode); struct Curl_tree *newnode);
#if 0 #if 0
struct Curl_tree *Curl_splayremove(struct timeval key, struct Curl_tree *Curl_splayremove(struct curltime key,
struct Curl_tree *t, struct Curl_tree *t,
struct Curl_tree **removed); struct Curl_tree **removed);
#endif #endif
struct Curl_tree *Curl_splaygetbest(struct timeval key, struct Curl_tree *Curl_splaygetbest(struct curltime key,
struct Curl_tree *t, struct Curl_tree *t,
struct Curl_tree **removed); struct Curl_tree **removed);

View File

@ -2827,7 +2827,7 @@ static CURLcode ssh_block_statemach(struct connectdata *conn,
while((sshc->state != SSH_STOP) && !result) { while((sshc->state != SSH_STOP) && !result) {
bool block; bool block;
time_t left = 1000; time_t left = 1000;
struct timeval now = Curl_tvnow(); struct curltime now = Curl_tvnow();
result = ssh_statemach_act(conn, &block); result = ssh_statemach_act(conn, &block);
if(result) if(result)

View File

@ -1327,7 +1327,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
curl_off_t total_ul = 0; curl_off_t total_ul = 0;
#endif #endif
ssize_t nread; ssize_t nread;
struct timeval now; struct curltime now;
bool keepon = TRUE; bool keepon = TRUE;
char *buf = data->state.buffer; char *buf = data->state.buffer;
struct TELNET *tn; struct TELNET *tn;

View File

@ -24,14 +24,14 @@
#if defined(WIN32) && !defined(MSDOS) #if defined(WIN32) && !defined(MSDOS)
struct timeval curlx_tvnow(void) struct curltime curlx_tvnow(void)
{ {
/* /*
** GetTickCount() is available on _all_ Windows versions from W95 up ** GetTickCount() is available on _all_ Windows versions from W95 up
** to nowadays. Returns milliseconds elapsed since last system boot, ** to nowadays. Returns milliseconds elapsed since last system boot,
** increases monotonically and wraps once 49.7 days have elapsed. ** increases monotonically and wraps once 49.7 days have elapsed.
*/ */
struct timeval now; struct curltime now;
#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \ #if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \
(_WIN32_WINNT < _WIN32_WINNT_VISTA) (_WIN32_WINNT < _WIN32_WINNT_VISTA)
DWORD milliseconds = GetTickCount(); DWORD milliseconds = GetTickCount();
@ -39,8 +39,8 @@ struct timeval curlx_tvnow(void)
now.tv_usec = (milliseconds % 1000) * 1000; now.tv_usec = (milliseconds % 1000) * 1000;
#else #else
ULONGLONG milliseconds = GetTickCount64(); ULONGLONG milliseconds = GetTickCount64();
now.tv_sec = (long) (milliseconds / 1000); now.tv_sec = (time_t) (milliseconds / 1000);
now.tv_usec = (long) (milliseconds % 1000) * 1000; now.tv_usec = (unsigned int) (milliseconds % 1000) * 1000;
#endif #endif
return now; return now;
@ -48,7 +48,7 @@ struct timeval curlx_tvnow(void)
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC) #elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
struct timeval curlx_tvnow(void) struct curltime curlx_tvnow(void)
{ {
/* /*
** clock_gettime() is granted to be increased monotonically when the ** clock_gettime() is granted to be increased monotonically when the
@ -58,10 +58,11 @@ struct timeval curlx_tvnow(void)
** system has started up. ** system has started up.
*/ */
struct timeval now; struct timeval now;
struct curltime cnow;
struct timespec tsnow; struct timespec tsnow;
if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) { if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) {
now.tv_sec = tsnow.tv_sec; cnow.tv_sec = tsnow.tv_sec;
now.tv_usec = tsnow.tv_nsec / 1000; cnow.tv_usec = (unsigned int)(tsnow.tv_nsec / 1000);
} }
/* /*
** Even when the configure process has truly detected monotonic clock ** Even when the configure process has truly detected monotonic clock
@ -69,20 +70,23 @@ struct timeval curlx_tvnow(void)
** run-time. When this occurs simply fallback to other time source. ** run-time. When this occurs simply fallback to other time source.
*/ */
#ifdef HAVE_GETTIMEOFDAY #ifdef HAVE_GETTIMEOFDAY
else else {
(void)gettimeofday(&now, NULL); (void)gettimeofday(&now, NULL);
cnow.tv_sec = now.tv_sec;
cnow.tv_usec = (unsigned int)now.tv_usec;
}
#else #else
else { else {
now.tv_sec = (long)time(NULL); cnow.tv_sec = time(NULL);
now.tv_usec = 0; cnow.tv_usec = 0;
} }
#endif #endif
return now; return cnow;
} }
#elif defined(HAVE_GETTIMEOFDAY) #elif defined(HAVE_GETTIMEOFDAY)
struct timeval curlx_tvnow(void) struct curltime curlx_tvnow(void)
{ {
/* /*
** gettimeofday() is not granted to be increased monotonically, due to ** gettimeofday() is not granted to be increased monotonically, due to
@ -90,19 +94,22 @@ struct timeval curlx_tvnow(void)
** forward or backward in time. ** forward or backward in time.
*/ */
struct timeval now; struct timeval now;
struct curltime ret;
(void)gettimeofday(&now, NULL); (void)gettimeofday(&now, NULL);
return now; ret.tv_sec = now.tv_sec;
ret.tv_usec = now.tv_usec;
return ret;
} }
#else #else
struct timeval curlx_tvnow(void) struct curltime curlx_tvnow(void)
{ {
/* /*
** time() returns the value of time in seconds since the Epoch. ** time() returns the value of time in seconds since the Epoch.
*/ */
struct timeval now; struct curltime now;
now.tv_sec = (long)time(NULL); now.tv_sec = time(NULL);
now.tv_usec = 0; now.tv_usec = 0;
return now; return now;
} }
@ -115,8 +122,10 @@ struct timeval curlx_tvnow(void)
* *
* Returns: the time difference in number of milliseconds. For large diffs it * Returns: the time difference in number of milliseconds. For large diffs it
* returns 0x7fffffff on 32bit time_t systems. * returns 0x7fffffff on 32bit time_t systems.
*
* @unittest: 1323
*/ */
time_t curlx_tvdiff(struct timeval newer, struct timeval older) time_t curlx_tvdiff(struct curltime newer, struct curltime older)
{ {
#if SIZEOF_TIME_T < 8 #if SIZEOF_TIME_T < 8
/* for 32bit time_t systems, add a precaution to avoid overflow for really /* for 32bit time_t systems, add a precaution to avoid overflow for really
@ -126,7 +135,7 @@ time_t curlx_tvdiff(struct timeval newer, struct timeval older)
return 0x7fffffff; return 0x7fffffff;
#endif #endif
return (newer.tv_sec-older.tv_sec)*1000+ return (newer.tv_sec-older.tv_sec)*1000+
(time_t)(newer.tv_usec-older.tv_usec)/1000; (int)(newer.tv_usec-older.tv_usec)/1000;
} }
/* /*
@ -136,7 +145,7 @@ time_t curlx_tvdiff(struct timeval newer, struct timeval older)
* Returns: the time difference in number of microseconds. For too large diffs * Returns: the time difference in number of microseconds. For too large diffs
* it returns max value. * it returns max value.
*/ */
time_t Curl_tvdiff_us(struct timeval newer, struct timeval older) time_t Curl_tvdiff_us(struct curltime newer, struct curltime older)
{ {
time_t diff = newer.tv_sec-older.tv_sec; time_t diff = newer.tv_sec-older.tv_sec;
#if SIZEOF_TIME_T < 8 #if SIZEOF_TIME_T < 8

View File

@ -29,7 +29,12 @@
#include "curl_setup.h" #include "curl_setup.h"
struct timeval curlx_tvnow(void); struct curltime {
time_t tv_sec; /* seconds */
unsigned int tv_usec; /* microseconds */
};
struct curltime curlx_tvnow(void);
/* /*
* Make sure that the first argument (t1) is the more recent time and t2 is * Make sure that the first argument (t1) is the more recent time and t2 is
@ -37,7 +42,7 @@ struct timeval curlx_tvnow(void);
* *
* Returns: the time difference in number of milliseconds. * Returns: the time difference in number of milliseconds.
*/ */
time_t curlx_tvdiff(struct timeval t1, struct timeval t2); time_t curlx_tvdiff(struct curltime t1, struct curltime t2);
/* /*
* Make sure that the first argument (t1) is the more recent time and t2 is * Make sure that the first argument (t1) is the more recent time and t2 is
@ -45,7 +50,7 @@ time_t curlx_tvdiff(struct timeval t1, struct timeval t2);
* *
* Returns: the time difference in number of microseconds. * Returns: the time difference in number of microseconds.
*/ */
time_t Curl_tvdiff_us(struct timeval newer, struct timeval older); time_t Curl_tvdiff_us(struct curltime newer, struct curltime older);
/* These two defines below exist to provide the older API for library /* These two defines below exist to provide the older API for library
internals only. */ internals only. */

View File

@ -3275,7 +3275,7 @@ Curl_oldest_idle_connection(struct Curl_easy *data)
struct curl_hash_element *he; struct curl_hash_element *he;
time_t highscore=-1; time_t highscore=-1;
time_t score; time_t score;
struct timeval now; struct curltime now;
struct connectdata *conn_candidate = NULL; struct connectdata *conn_candidate = NULL;
struct connectbundle *bundle; struct connectbundle *bundle;
@ -3338,7 +3338,7 @@ find_oldest_idle_connection_in_bundle(struct Curl_easy *data,
struct curl_llist_element *curr; struct curl_llist_element *curr;
time_t highscore=-1; time_t highscore=-1;
time_t score; time_t score;
struct timeval now; struct curltime now;
struct connectdata *conn_candidate = NULL; struct connectdata *conn_candidate = NULL;
struct connectdata *conn; struct connectdata *conn;
@ -3426,7 +3426,7 @@ static int call_disconnect_if_dead(struct connectdata *conn,
*/ */
static void prune_dead_connections(struct Curl_easy *data) static void prune_dead_connections(struct Curl_easy *data)
{ {
struct timeval now = Curl_tvnow(); struct curltime now = Curl_tvnow();
time_t elapsed = Curl_tvdiff(now, data->state.conn_cache->last_cleanup); time_t elapsed = Curl_tvdiff(now, data->state.conn_cache->last_cleanup);
if(elapsed >= 1000L) { if(elapsed >= 1000L) {

View File

@ -678,8 +678,8 @@ struct SingleRequest {
100 reply (without a following second response 100 reply (without a following second response
code) result in a CURLE_GOT_NOTHING error code */ code) result in a CURLE_GOT_NOTHING error code */
struct timeval start; /* transfer started at this time */ struct curltime start; /* transfer started at this time */
struct timeval now; /* current time */ struct curltime now; /* current time */
bool header; /* incoming data has HTTP header */ bool header; /* incoming data has HTTP header */
enum { enum {
HEADER_NORMAL, /* no bad header at all */ HEADER_NORMAL, /* no bad header at all */
@ -701,7 +701,7 @@ struct SingleRequest {
Content-Range: header */ Content-Range: header */
int httpcode; /* error code from the 'HTTP/1.? XXX' or int httpcode; /* error code from the 'HTTP/1.? XXX' or
'RTSP/1.? XXX' line */ 'RTSP/1.? XXX' line */
struct timeval start100; /* time stamp to wait for the 100 code from */ struct curltime start100; /* time stamp to wait for the 100 code from */
enum expect100 exp100; /* expect 100 continue state */ enum expect100 exp100; /* expect 100 continue state */
enum upgrade101 upgr101; /* 101 upgrade state */ enum upgrade101 upgr101; /* 101 upgrade state */
@ -1016,8 +1016,8 @@ struct connectdata {
int httpversion; /* the HTTP version*10 reported by the server */ int httpversion; /* the HTTP version*10 reported by the server */
int rtspversion; /* the RTSP version*10 reported by the server */ int rtspversion; /* the RTSP version*10 reported by the server */
struct timeval now; /* "current" time */ struct curltime now; /* "current" time */
struct timeval created; /* creation time */ struct curltime created; /* creation time */
curl_socket_t sock[2]; /* two sockets, the second is used for the data curl_socket_t sock[2]; /* two sockets, the second is used for the data
transfer when doing FTP */ transfer when doing FTP */
curl_socket_t tempsock[2]; /* temporary sockets for happy eyeballs */ curl_socket_t tempsock[2]; /* temporary sockets for happy eyeballs */
@ -1040,7 +1040,7 @@ struct connectdata {
/* connecttime: when connect() is called on the current IP address. Used to /* connecttime: when connect() is called on the current IP address. Used to
be able to track when to move on to try next IP - but only when the multi be able to track when to move on to try next IP - but only when the multi
interface is used. */ interface is used. */
struct timeval connecttime; struct curltime connecttime;
/* The two fields below get set in Curl_connecthost */ /* The two fields below get set in Curl_connecthost */
int num_addr; /* number of addresses to try to connect to */ int num_addr; /* number of addresses to try to connect to */
time_t timeoutms_per_addr; /* how long time in milliseconds to spend on time_t timeoutms_per_addr; /* how long time in milliseconds to spend on
@ -1250,22 +1250,22 @@ struct Progress {
time_t t_starttransfer; time_t t_starttransfer;
time_t t_redirect; time_t t_redirect;
struct timeval start; struct curltime start;
struct timeval t_startsingle; struct curltime t_startsingle;
struct timeval t_startop; struct curltime t_startop;
struct timeval t_acceptdata; struct curltime t_acceptdata;
/* upload speed limit */ /* upload speed limit */
struct timeval ul_limit_start; struct curltime ul_limit_start;
curl_off_t ul_limit_size; curl_off_t ul_limit_size;
/* download speed limit */ /* download speed limit */
struct timeval dl_limit_start; struct curltime dl_limit_start;
curl_off_t dl_limit_size; curl_off_t dl_limit_size;
#define CURR_TIME (5+1) /* 6 entries for 5 seconds */ #define CURR_TIME (5+1) /* 6 entries for 5 seconds */
curl_off_t speeder[ CURR_TIME ]; curl_off_t speeder[ CURR_TIME ];
struct timeval speeder_time[ CURR_TIME ]; struct curltime speeder_time[ CURR_TIME ];
int speeder_c; int speeder_c;
}; };
@ -1360,7 +1360,7 @@ typedef enum {
*/ */
struct time_node { struct time_node {
struct curl_llist_element list; struct curl_llist_element list;
struct timeval time; struct curltime time;
expire_id eid; expire_id eid;
}; };
@ -1375,7 +1375,7 @@ struct UrlState {
bool multi_owned_by_easy; bool multi_owned_by_easy;
/* buffers to store authentication data in, as parsed from input options */ /* buffers to store authentication data in, as parsed from input options */
struct timeval keeps_speed; /* for the progress meter really */ struct curltime keeps_speed; /* for the progress meter really */
struct connectdata *lastconnect; /* The last connection, NULL if undefined */ struct connectdata *lastconnect; /* The last connection, NULL if undefined */
@ -1429,7 +1429,7 @@ struct UrlState {
#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H) #if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H)
ENGINE *engine; ENGINE *engine;
#endif /* USE_OPENSSL */ #endif /* USE_OPENSSL */
struct timeval expiretime; /* set this with Curl_expire() only */ struct curltime expiretime; /* set this with Curl_expire() only */
struct Curl_tree timenode; /* for the splay stuff */ struct Curl_tree timenode; /* for the splay stuff */
struct curl_llist timeoutlist; /* list of pending timeouts */ struct curl_llist timeoutlist; /* list of pending timeouts */
struct time_node expires[EXPIRE_LAST]; /* nodes for each expire type */ struct time_node expires[EXPIRE_LAST]; /* nodes for each expire type */

View File

@ -290,16 +290,18 @@ static CURLcode Curl_ossl_seed(struct Curl_easy *data)
unsigned char randb[64]; unsigned char randb[64];
size_t len = sizeof(randb); size_t len = sizeof(randb);
size_t i, i_max; size_t i, i_max;
for(i = 0, i_max = len / sizeof(struct timeval); i < i_max; ++i) { for(i = 0, i_max = len / sizeof(struct curltime); i < i_max; ++i) {
struct timeval tv = curlx_tvnow(); struct curltime tv = curlx_tvnow();
Curl_wait_ms(1); Curl_wait_ms(1);
tv.tv_sec *= i + 1; tv.tv_sec *= i + 1;
tv.tv_usec *= i + 2; tv.tv_usec *= (unsigned int)i + 2;
tv.tv_sec ^= ((curlx_tvnow().tv_sec + curlx_tvnow().tv_usec) * tv.tv_sec ^= ((curlx_tvnow().tv_sec + curlx_tvnow().tv_usec) *
(i + 3)) << 8; (i + 3)) << 8;
tv.tv_usec ^= ((curlx_tvnow().tv_sec + curlx_tvnow().tv_usec) * tv.tv_usec ^= (unsigned int) ((curlx_tvnow().tv_sec +
(i + 4)) << 16; curlx_tvnow().tv_usec) *
memcpy(&randb[i * sizeof(struct timeval)], &tv, sizeof(struct timeval)); (i + 4)) << 16;
memcpy(&randb[i * sizeof(struct curltime)], &tv,
sizeof(struct curltime));
} }
RAND_add(randb, (int)len, (double)len/2); RAND_add(randb, (int)len, (double)len/2);
} while(!rand_enough()); } while(!rand_enough());

View File

@ -5,7 +5,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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -100,7 +100,7 @@ void logmsg(const char *msg, ...)
char buffer[2048 + 1]; char buffer[2048 + 1];
FILE *logfp; FILE *logfp;
int error; int error;
struct timeval tv; struct curltime tv;
time_t sec; time_t sec;
struct tm *now; struct tm *now;
char timebuf[20]; char timebuf[20];
@ -211,9 +211,9 @@ int wait_ms(int timeout_ms)
{ {
#if !defined(MSDOS) && !defined(USE_WINSOCK) #if !defined(MSDOS) && !defined(USE_WINSOCK)
#ifndef HAVE_POLL_FINE #ifndef HAVE_POLL_FINE
struct timeval pending_tv; struct curltime pending_tv;
#endif #endif
struct timeval initial_tv; struct curltime initial_tv;
int pending_ms; int pending_ms;
int error; int error;
#endif #endif

View File

@ -5,7 +5,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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -70,7 +70,7 @@ struct timetest {
UNITTEST_START UNITTEST_START
{ {
struct timeval now; struct curltime now;
time_t timeout; time_t timeout;
unsigned int i; unsigned int i;

View File

@ -74,17 +74,19 @@ UNITTEST_START
struct Curl_tree nodes[NUM_NODES*3]; struct Curl_tree nodes[NUM_NODES*3];
int rc; int rc;
int i, j; int i, j;
struct timeval tv_now = {0, 0}; struct curltime tv_now = {0, 0};
root = NULL; /* the empty tree */ root = NULL; /* the empty tree */
/* add nodes */ /* add nodes */
for(i = 0; i < NUM_NODES; i++) { for(i = 0; i < NUM_NODES; i++) {
struct timeval key; struct curltime key;
size_t payload;
key.tv_sec = 0; key.tv_sec = 0;
key.tv_usec = (541*i)%1023; key.tv_usec = (541*i)%1023;
payload = (size_t) key.tv_usec;
nodes[i].payload = (void *)key.tv_usec; /* for simplicity */ nodes[i].payload = (void *)payload; /* for simplicity */
root = Curl_splayinsert(key, root, &nodes[i]); root = Curl_splayinsert(key, root, &nodes[i]);
} }
@ -109,14 +111,15 @@ UNITTEST_START
/* rebuild tree */ /* rebuild tree */
for(i = 0; i < NUM_NODES; i++) { for(i = 0; i < NUM_NODES; i++) {
struct timeval key; struct curltime key;
key.tv_sec = 0; key.tv_sec = 0;
key.tv_usec = (541*i)%1023; key.tv_usec = (541*i)%1023;
/* add some nodes with the same key */ /* add some nodes with the same key */
for(j = 0; j <= i % 3; j++) { for(j = 0; j <= i % 3; j++) {
nodes[i*3+j].payload = (void *)(key.tv_usec*10 + j); /* for simplicity */ size_t payload = key.tv_usec*10 + j;
nodes[i*3+j].payload = (void *)payload; /* for simplicity */
root = Curl_splayinsert(key, root, &nodes[i*3+j]); root = Curl_splayinsert(key, root, &nodes[i*3+j]);
} }
} }

View File

@ -48,7 +48,7 @@ static bool usec_matches_seconds(time_t time_usec, int expected_seconds)
UNITTEST_START UNITTEST_START
struct Curl_easy data; struct Curl_easy data;
struct timeval now = Curl_tvnow(); struct curltime now = Curl_tvnow();
data.progress.t_starttransfer = 0; data.progress.t_starttransfer = 0;
data.progress.t_redirect = 0; data.progress.t_redirect = 0;

View File

@ -41,7 +41,7 @@ static int runawhile(struct Curl_easy *easy,
int dec) int dec)
{ {
int counter = 1; int counter = 1;
struct timeval now = {1, 0}; struct curltime now = {1, 0};
CURLcode result; CURLcode result;
int finaltime; int finaltime;