CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
long timeout;
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
struct Curl_dns_entry *temp_entry;
if(entry)
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else {
- struct curltime now2 = Curl_tvnow();
+ struct curltime now2 = Curl_now();
timediff_t timediff = Curl_timediff(now2, now); /* spent time */
if(timediff <= 0)
timeout -= 1; /* always deduct at least 1 */
}
else {
/* 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);
if(elapsed < 0)
elapsed = 0;
}
if(!nowp) {
- now = Curl_tvnow();
+ now = Curl_now();
nowp = &now;
}
return CURLE_OK;
}
- now = Curl_tvnow();
+ now = Curl_now();
/* figure out how long time we have left to connect */
allow = Curl_timeleft(data, &now, TRUE);
/* set socket non-blocking */
(void)curlx_nonblock(sockfd, TRUE);
- conn->connecttime = Curl_tvnow();
+ conn->connecttime = Curl_now();
if(conn->num_addr > 1)
Curl_expire(data, conn->timeoutms_per_addr, EXPIRE_DNS_PER_NAME);
const struct Curl_dns_entry *remotehost)
{
struct Curl_easy *data = conn->data;
- struct curltime before = Curl_tvnow();
+ struct curltime before = Curl_now();
CURLcode result = CURLE_COULDNT_CONNECT;
time_t timeout_ms = Curl_timeleft(data, &before, TRUE);
}
/* get the time stamp to use to figure out how long poll takes */
- before = Curl_tvnow();
+ before = Curl_now();
/* wait for activity or timeout */
pollrc = Curl_poll(fds, numfds, (int)ev->ms);
- after = Curl_tvnow();
+ after = Curl_now();
ev->msbump = FALSE; /* reset here */
int still_running = 0;
int rc;
- before = Curl_tvnow();
+ before = Curl_now();
mcode = curl_multi_wait(multi, NULL, 0, 1000, &rc);
if(!mcode) {
if(!rc) {
- struct curltime after = Curl_tvnow();
+ struct curltime after = Curl_now();
/* If it returns without any filedescriptor instantly, we need to
avoid busy-looping during periods where it has nothing particular
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
- result = Curl_speedcheck(data, Curl_tvnow());
+ result = Curl_speedcheck(data, Curl_now());
}
if(!result && Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
- result = Curl_speedcheck(data, Curl_tvnow());
+ result = Curl_speedcheck(data, Curl_now());
}
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
if(data->set.accepttimeout > 0)
timeout_ms = data->set.accepttimeout;
- now = Curl_tvnow();
+ now = Curl_now();
/* check if the generic timeout possibly is set shorter */
other = Curl_timeleft(data, &now, FALSE);
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 */
+ pp->response = Curl_now(); /* timeout relative now */
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
PPSENDF(&conn->proto.ftpc.pp, "%s", cmd);
- pp->response = Curl_tvnow(); /* timeout relative now */
+ pp->response = Curl_now(); /* timeout relative now */
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
the time we spent until now! */
if(prev_alarm) {
/* there was an alarm() set before us, now put it back */
- timediff_t elapsed_secs = Curl_timediff(Curl_tvnow(),
+ timediff_t elapsed_secs = Curl_timediff(Curl_now(),
conn->created) / 1000;
/* the alarm period is counted in even number of seconds */
struct Curl_easy *data;
CURLMcode returncode = CURLM_OK;
struct Curl_tree *t;
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
CURLMcode result = CURLM_OK;
struct Curl_easy *data = NULL;
struct Curl_tree *t;
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
if(checkall) {
/* *perform() deals with running_handles on its own */
data = NULL; /* set data to NULL again to avoid calling
multi_runsingle() in case there's no need to */
- now = Curl_tvnow(); /* get a newer time since the multi_runsingle() loop
- may have taken some time */
+ now = Curl_now(); /* get a newer time since the multi_runsingle() loop
+ may have taken some time */
}
}
else {
if(multi->timetree) {
/* we have a tree of expire times */
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
/* splay the lowest to the bottom */
multi->timetree = Curl_splay(tv_zero, multi->timetree);
DEBUGASSERT(id < EXPIRE_LAST);
- set = Curl_tvnow();
+ set = Curl_now();
set.tv_sec += milli/1000;
set.tv_usec += (unsigned int)(milli%1000)*1000;
/* 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_timediff(Curl_tvnow(), pp->response); /* spent time */
+ Curl_timediff(Curl_now(), pp->response); /* spent time */
if(data->set.timeout) {
/* if timeout is requested, find out how much remaining time we have */
timeout2_ms = data->set.timeout - /* timeout time */
- Curl_timediff(Curl_tvnow(), conn->now); /* spent time */
+ Curl_timediff(Curl_now(), conn->now); /* spent time */
/* pick the lowest number */
timeout_ms = CURLMIN(timeout_ms, timeout2_ms);
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
- result = Curl_speedcheck(data, Curl_tvnow());
+ result = Curl_speedcheck(data, Curl_now());
if(result)
return result;
pp->nread_resp = 0;
pp->linestart_resp = conn->data->state.buffer;
pp->pending_resp = TRUE;
- pp->response = Curl_tvnow(); /* start response time-out now! */
+ pp->response = Curl_now(); /* start response time-out now! */
}
free(s);
pp->sendthis = NULL;
pp->sendleft = pp->sendsize = 0;
- pp->response = Curl_tvnow();
+ pp->response = Curl_now();
}
return CURLE_OK;
free(pp->sendthis);
pp->sendthis = NULL;
pp->sendleft = pp->sendsize = 0;
- pp->response = Curl_tvnow();
+ pp->response = Curl_now();
}
return CURLE_OK;
}
server */
size_t sendleft; /* number of bytes left to send from the sendthis buffer */
size_t sendsize; /* total size of the sendthis buffer */
- struct curltime response; /* set to Curl_tvnow() when a command has been sent
- off, used to time-out response reading */
+ struct curltime response; /* set to Curl_now() when a command has been sent
+ off, used to time-out response reading */
long response_time; /* When no timeout is given, this is the amount of
milliseconds we await for a server response. */
*/
void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
{
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
time_t *delta = NULL;
switch(timer) {
void Curl_pgrsStartNow(struct Curl_easy *data)
{
data->progress.speeder_c = 0; /* reset the progress meter display */
- data->progress.start = Curl_tvnow();
+ data->progress.start = Curl_now();
data->progress.is_t_startransfer_set = false;
data->progress.ul_limit_start.tv_sec = 0;
data->progress.ul_limit_start.tv_usec = 0;
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
{
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
data->progress.downloaded = size;
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size)
{
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
data->progress.uploaded = size;
curl_off_t total_estimate;
bool shownow = FALSE;
- now = Curl_tvnow(); /* what time is it */
+ now = Curl_now(); /* what time is it */
/* The time spent so far (from the start) */
data->progress.timespent = Curl_timediff_us(now, data->progress.start);
#endif
if(!seeded) {
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
infof(data, "WARNING: Using weak random seed\n");
randseed += (unsigned int)now.tv_usec + (unsigned int)now.tv_sec;
randseed = randseed * 1103515245 + 12345;
#include "warnless.h"
/* Convenience local macros */
-#define ELAPSED_MS() (int)Curl_timediff(Curl_tvnow(), initial_tv)
+#define ELAPSED_MS() (int)Curl_timediff(Curl_now(), initial_tv)
int Curl_ack_eintr = 0;
#define ERROR_NOT_EINTR(error) (Curl_ack_eintr || error != EINTR)
Sleep(timeout_ms);
#else
pending_ms = timeout_ms;
- initial_tv = Curl_tvnow();
+ initial_tv = Curl_now();
do {
#if defined(HAVE_POLL_FINE)
r = poll(NULL, 0, pending_ms);
if(timeout_ms > 0) {
pending_ms = (int)timeout_ms;
- initial_tv = Curl_tvnow();
+ initial_tv = Curl_now();
}
#ifdef HAVE_POLL_FINE
if(timeout_ms > 0) {
pending_ms = timeout_ms;
- initial_tv = Curl_tvnow();
+ initial_tv = Curl_now();
}
#ifdef HAVE_POLL_FINE
}
else {
/* Successfully sent so adjust the response timeout relative to now */
- pp->response = Curl_tvnow();
+ pp->response = Curl_now();
free(eob);
}
while((sshc->state != SSH_STOP) && !result) {
bool block;
time_t left = 1000;
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
result = ssh_statemach_act(conn, &block);
if(result)
}
if(data->set.timeout) {
- now = Curl_tvnow();
+ now = Curl_now();
if(Curl_timediff(now, conn->created) >= data->set.timeout) {
failf(data, "Time-out");
result = CURLE_OPERATION_TIMEDOUT;
} /* poll switch statement */
if(data->set.timeout) {
- now = Curl_tvnow();
+ now = Curl_now();
if(Curl_timediff(now, conn->created) >= data->set.timeout) {
failf(data, "Time-out");
result = CURLE_OPERATION_TIMEDOUT;
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
- result = Curl_speedcheck(conn->data, Curl_tvnow());
+ result = Curl_speedcheck(conn->data, Curl_now());
}
return result;
}
#if defined(WIN32) && !defined(MSDOS)
-struct curltime Curl_tvnow(void)
+struct curltime Curl_now(void)
{
/*
** GetTickCount() is available on _all_ Windows versions from W95 up
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
-struct curltime Curl_tvnow(void)
+struct curltime Curl_now(void)
{
/*
** clock_gettime() is granted to be increased monotonically when the
#elif defined(HAVE_GETTIMEOFDAY)
-struct curltime Curl_tvnow(void)
+struct curltime Curl_now(void)
{
/*
** gettimeofday() is not granted to be increased monotonically, due to
#else
-struct curltime Curl_tvnow(void)
+struct curltime Curl_now(void)
{
/*
** time() returns the value of time in seconds since the Epoch.
#endif
/*
- * Make sure that the first argument is the more recent time, as otherwise
- * we'll get a weird negative time-diff back...
- *
- * Returns: the time difference in number of milliseconds. For large diffs it
- * returns 0x7fffffff on 32bit time_t systems.
+ * Returns: time difference in number of milliseconds. For too large diffs it
+ * returns max value.
*
* @unittest: 1323
*/
return TIME_MAX;
else if(diff <= (TIME_MIN/1000))
return TIME_MIN;
- return (timediff_t)(newer.tv_sec-older.tv_sec)*1000+
- (timediff_t)(newer.tv_usec-older.tv_usec)/1000;
+ return diff * 1000 + (newer.tv_usec-older.tv_usec)/1000;
}
/*
- * Make sure that the first argument is the more recent time, as otherwise
- * we'll get a weird negative time-diff back...
- *
- * Returns: the time difference in number of microseconds. For too large diffs
- * it returns max value.
+ * Returns: time difference in number of microseconds. For too large diffs it
+ * returns max value.
*/
timediff_t Curl_timediff_us(struct curltime newer, struct curltime older)
{
return TIME_MAX;
else if(diff <= (TIME_MIN/1000000))
return TIME_MIN;
- return (timediff_t)(newer.tv_sec-older.tv_sec)*1000000+
- (timediff_t)(newer.tv_usec-older.tv_usec);
+ return diff * 1000000 + newer.tv_usec-older.tv_usec;
}
typedef ssize_t timediff_t;
#endif
-
struct curltime {
time_t tv_sec; /* seconds */
int tv_usec; /* microseconds */
};
-struct curltime Curl_tvnow(void);
+struct curltime Curl_now(void);
/*
* Make sure that the first argument (t1) is the more recent time and t2 is
timediff_t Curl_timediff_us(struct curltime newer, struct curltime older);
#endif /* HEADER_CURL_TIMEVAL_H */
-
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
if(k->exp100 > EXP100_SEND_DATA)
/* set time stamp to compare with when waiting for the 100 */
- k->start100 = Curl_tvnow();
+ k->start100 = Curl_now();
}
*didwhat |= KEEP_RECV;
go into the Expect: 100 state and await such a header */
k->exp100 = EXP100_AWAITING_CONTINUE; /* wait for the header */
k->keepon &= ~KEEP_SEND; /* disable writing */
- k->start100 = Curl_tvnow(); /* timeout count starts now */
+ k->start100 = Curl_now(); /* timeout count starts now */
*didwhat &= ~KEEP_SEND; /* we didn't write anything actually */
/* set a timeout for the multi interface */
return result;
}
- k->now = Curl_tvnow();
+ k->now = Curl_now();
if(didwhat) {
/* Update read/write counters */
if(k->bytecountp)
(http->sending == HTTPSEND_BODY)) {
/* wait with write until we either got 100-continue or a timeout */
k->exp100 = EXP100_AWAITING_CONTINUE;
- k->start100 = Curl_tvnow();
+ k->start100 = Curl_now();
/* Set a timeout for the multi interface. Add the inaccuracy margin so
that we don't fire slightly too early and get denied to run. */
struct connectdata *conn_candidate = NULL;
struct connectbundle *bundle;
- now = Curl_tvnow();
+ now = Curl_now();
Curl_hash_start_iterate(&bc->hash, &iter);
(void)data;
- now = Curl_tvnow();
+ now = Curl_now();
curr = bundle->conn_list.head;
while(curr) {
*/
static void prune_dead_connections(struct Curl_easy *data)
{
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
time_t elapsed = Curl_timediff(now, data->state.conn_cache->last_cleanup);
if(elapsed >= 1000L) {
connclose(conn, "Default to force-close");
/* Store creation time to help future close decision making */
- conn->created = Curl_tvnow();
+ conn->created = Curl_now();
conn->data = data; /* Setup the association between this connection
and the Curl_easy */
/* 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();
+ conn->now = Curl_now();
if(CURL_SOCKET_BAD == conn->sock[FIRSTSOCKET]) {
conn->bits.tcpconnect[FIRSTSOCKET] = FALSE;
Curl_verboseconnect(conn);
}
- conn->now = Curl_tvnow(); /* time this *after* the connect is done, we
+ conn->now = Curl_now(); /* time this *after* the connect is done, we
set this here perhaps a second time */
#ifdef __EMX__
HTTP. */
data->set.httpreq = HTTPREQ_GET;
- k->start = Curl_tvnow(); /* start time */
+ k->start = Curl_now(); /* start time */
k->now = k->start; /* current time is now */
k->header = TRUE; /* assume header */
size_t len = sizeof(randb);
size_t i, i_max;
for(i = 0, i_max = len / sizeof(struct curltime); i < i_max; ++i) {
- struct curltime tv = Curl_tvnow();
+ struct curltime tv = Curl_now();
Curl_wait_ms(1);
tv.tv_sec *= i + 1;
tv.tv_usec *= (unsigned int)i + 2;
- tv.tv_sec ^= ((Curl_tvnow().tv_sec + Curl_tvnow().tv_usec) *
+ tv.tv_sec ^= ((Curl_now().tv_sec + Curl_now().tv_usec) *
(i + 3)) << 8;
- tv.tv_usec ^= (unsigned int) ((Curl_tvnow().tv_sec +
- Curl_tvnow().tv_usec) *
+ tv.tv_usec ^= (unsigned int) ((Curl_now().tv_sec +
+ Curl_now().tv_usec) *
(i + 4)) << 16;
memcpy(&randb[i * sizeof(struct curltime)], &tv,
sizeof(struct curltime));
* be 3 seconds. */
UNITTEST_START
struct Curl_easy data;
- struct curltime now = Curl_tvnow();
+ struct curltime now = Curl_now();
data.progress.t_nslookup = 0;
data.progress.t_connect = 0;