2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 01:59:26 +00:00

Refactor isc_time_now() to return time, and not result

The isc_time_now() and isc_time_now_hires() were used inconsistently
through the code - either with status check, or without status check,
or via TIME_NOW() macro with RUNTIME_CHECK() on failure.

Refactor the isc_time_now() and isc_time_now_hires() to always fail when
getting current time has failed, and return the isc_time_t value as
return value instead of passing the pointer to result in the argument.
This commit is contained in:
Ondřej Surý 2023-03-31 00:12:33 +02:00
parent da039ec2b3
commit a5f5f68502
No known key found for this signature in database
GPG Key ID: 2820F37E873DEA41
39 changed files with 228 additions and 226 deletions

View File

@ -422,7 +422,7 @@ debug(const char *format, ...) {
if (debugging) { if (debugging) {
fflush(stdout); fflush(stdout);
if (debugtiming) { if (debugtiming) {
TIME_NOW(&t); t = isc_time_now();
fprintf(stderr, "%u.%06u: ", isc_time_seconds(&t), fprintf(stderr, "%u.%06u: ", isc_time_seconds(&t),
isc_time_nanoseconds(&t) / 1000); isc_time_nanoseconds(&t) / 1000);
} }
@ -3104,9 +3104,9 @@ send_udp(dig_query_t *query) {
isc_buffer_usedregion(&query->sendbuf, &r); isc_buffer_usedregion(&query->sendbuf, &r);
debug("sending a request"); debug("sending a request");
if (query->lookup->use_usec) { if (query->lookup->use_usec) {
TIME_NOW_HIRES(&query->time_sent); query->time_sent = isc_time_now_hires();
} else { } else {
TIME_NOW(&query->time_sent); query->time_sent = isc_time_now();
} }
isc_nmhandle_attach(query->handle, &query->sendhandle); isc_nmhandle_attach(query->handle, &query->sendhandle);
@ -3471,9 +3471,9 @@ launch_next_query(dig_query_t *query) {
dig_query_t *sendquery = NULL; dig_query_t *sendquery = NULL;
debug("sending a request in launch_next_query"); debug("sending a request in launch_next_query");
if (query->lookup->use_usec) { if (query->lookup->use_usec) {
TIME_NOW_HIRES(&query->time_sent); query->time_sent = isc_time_now_hires();
} else { } else {
TIME_NOW(&query->time_sent); query->time_sent = isc_time_now();
} }
query_attach(query, &sendquery); query_attach(query, &sendquery);
@ -3926,9 +3926,9 @@ recv_done(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
} }
if (query->lookup->use_usec) { if (query->lookup->use_usec) {
TIME_NOW_HIRES(&query->time_recv); query->time_recv = isc_time_now_hires();
} else { } else {
TIME_NOW(&query->time_recv); query->time_recv = isc_time_now();
} }
if ((!l->pending && !l->ns_search_only) || cancel_now) { if ((!l->pending && !l->ns_search_only) || cancel_now) {

View File

@ -149,9 +149,9 @@ received(unsigned int bytes, isc_sockaddr_t *from, dig_query_t *query) {
char fromtext[ISC_SOCKADDR_FORMATSIZE]; char fromtext[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_format(from, fromtext, sizeof(fromtext)); isc_sockaddr_format(from, fromtext, sizeof(fromtext));
if (query->lookup->use_usec) { if (query->lookup->use_usec) {
TIME_NOW_HIRES(&now); now = isc_time_now_hires();
} else { } else {
TIME_NOW(&now); now = isc_time_now();
} }
diff = (int)isc_time_microdiff(&now, &query->time_sent); diff = (int)isc_time_microdiff(&now, &query->time_sent);
printf("Received %u bytes from %s in %d ms\n", bytes, fromtext, printf("Received %u bytes from %s in %d ms\n", bytes, fromtext,

View File

@ -3824,7 +3824,7 @@ main(int argc, char *argv[]) {
check_result(result, "dns_master_stylecreate"); check_result(result, "dns_master_stylecreate");
gdb = NULL; gdb = NULL;
TIME_NOW(&timer_start); timer_start = isc_time_now();
loadzone(file, origin, rdclass, &gdb); loadzone(file, origin, rdclass, &gdb);
if (journal != NULL) { if (journal != NULL) {
loadjournal(mctx, gdb, journal); loadjournal(mctx, gdb, journal);
@ -4014,7 +4014,7 @@ main(int argc, char *argv[]) {
} }
presign(); presign();
TIME_NOW(&sign_start); sign_start = isc_time_now();
signapex(); signapex();
if (!atomic_load(&finished)) { if (!atomic_load(&finished)) {
/* /*
@ -4030,7 +4030,7 @@ main(int argc, char *argv[]) {
} }
} }
postsign(); postsign();
TIME_NOW(&sign_finish); sign_finish = isc_time_now();
if (disable_zone_check) { if (disable_zone_check) {
vresult = ISC_R_SUCCESS; vresult = ISC_R_SUCCESS;
@ -4107,7 +4107,7 @@ main(int argc, char *argv[]) {
isc_managers_destroy(&mctx, &loopmgr, &netmgr); isc_managers_destroy(&mctx, &loopmgr, &netmgr);
if (printstats) { if (printstats) {
TIME_NOW(&timer_finish); timer_finish = isc_time_now();
print_stats(&timer_start, &timer_finish, &sign_start, print_stats(&timer_start, &timer_finish, &sign_start,
&sign_finish); &sign_finish);
isc_mutex_destroy(&statslock); isc_mutex_destroy(&statslock);

View File

@ -1214,11 +1214,7 @@ setup(void) {
/* /*
* Record the server's startup time. * Record the server's startup time.
*/ */
result = isc_time_now(&named_g_boottime); named_g_boottime = isc_time_now();
if (result != ISC_R_SUCCESS) {
named_main_earlyfatal("isc_time_now() failed: %s",
isc_result_totext(result));
}
result = create_managers(); result = create_managers();
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {

View File

@ -8275,7 +8275,7 @@ load_configuration(const char *filename, named_server_t *server,
isc_logconfig_t *logc = NULL; isc_logconfig_t *logc = NULL;
isc_portset_t *v4portset = NULL; isc_portset_t *v4portset = NULL;
isc_portset_t *v6portset = NULL; isc_portset_t *v6portset = NULL;
isc_result_t result, tresult; isc_result_t result;
uint32_t heartbeat_interval; uint32_t heartbeat_interval;
uint32_t interface_interval; uint32_t interface_interval;
uint32_t udpsize; uint32_t udpsize;
@ -9665,11 +9665,7 @@ load_configuration(const char *filename, named_server_t *server,
/* /*
* Record the time of most recent configuration * Record the time of most recent configuration
*/ */
tresult = isc_time_now(&named_g_configtime); named_g_configtime = isc_time_now();
if (tresult != ISC_R_SUCCESS) {
named_main_earlyfatal("isc_time_now() failed: %s",
isc_result_totext(result));
}
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume(named_g_loopmgr);
exclusive = false; exclusive = false;
@ -11640,7 +11636,7 @@ named_server_dumpsecroots(named_server_t *server, isc_lex_t *lex,
} }
} }
TIME_NOW(&now); now = isc_time_now();
isc_time_formattimestamp(&now, tbuf, sizeof(tbuf)); isc_time_formattimestamp(&now, tbuf, sizeof(tbuf));
CHECK(putstr(text, "secure roots as of ")); CHECK(putstr(text, "secure roots as of "));
CHECK(putstr(text, tbuf)); CHECK(putstr(text, tbuf));
@ -13894,7 +13890,7 @@ named_server_changezone(named_server_t *server, char *command,
addzone ? NAMED_COMMAND_ADDZONE : NAMED_COMMAND_MODZONE); addzone ? NAMED_COMMAND_ADDZONE : NAMED_COMMAND_MODZONE);
/* Changing a zone counts as reconfiguration */ /* Changing a zone counts as reconfiguration */
CHECK(isc_time_now(&named_g_configtime)); named_g_configtime = isc_time_now();
cleanup: cleanup:
if (isc_buffer_usedlength(*text) > 0) { if (isc_buffer_usedlength(*text) > 0) {
@ -14206,7 +14202,7 @@ named_server_delzone(named_server_t *server, isc_lex_t *lex,
"zone %s scheduled for removal via delzone", zonename); "zone %s scheduled for removal via delzone", zonename);
/* Removing a zone counts as reconfiguration */ /* Removing a zone counts as reconfiguration */
CHECK(isc_time_now(&named_g_configtime)); named_g_configtime = isc_time_now();
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
@ -14709,7 +14705,7 @@ named_server_dnssec(named_server_t *server, isc_lex_t *lex,
} }
/* Initialize current time and key list. */ /* Initialize current time and key list. */
TIME_NOW(&timenow); timenow = isc_time_now();
now = isc_time_seconds(&timenow); now = isc_time_seconds(&timenow);
when = now; when = now;

View File

@ -1969,7 +1969,7 @@ generatexml(named_server_t *server, uint32_t flags, int *buflen,
char boottime[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"]; char boottime[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
char configtime[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"]; char configtime[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
char nowstr[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"]; char nowstr[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
isc_time_t now; isc_time_t now = isc_time_now();
xmlTextWriterPtr writer = NULL; xmlTextWriterPtr writer = NULL;
xmlDocPtr doc = NULL; xmlDocPtr doc = NULL;
int xmlrc; int xmlrc;
@ -1990,7 +1990,6 @@ generatexml(named_server_t *server, uint32_t flags, int *buflen,
#endif /* ifdef HAVE_DNSTAP */ #endif /* ifdef HAVE_DNSTAP */
isc_result_t result; isc_result_t result;
isc_time_now(&now);
isc_time_formatISO8601ms(&named_g_boottime, boottime, sizeof boottime); isc_time_formatISO8601ms(&named_g_boottime, boottime, sizeof boottime);
isc_time_formatISO8601ms(&named_g_configtime, configtime, isc_time_formatISO8601ms(&named_g_configtime, configtime,
sizeof configtime); sizeof configtime);
@ -2779,7 +2778,7 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg,
CHECKMEM(obj); CHECKMEM(obj);
json_object_object_add(bindstats, "json-stats-version", obj); json_object_object_add(bindstats, "json-stats-version", obj);
isc_time_now(&now); now = isc_time_now();
isc_time_formatISO8601ms(&named_g_boottime, boottime, sizeof(boottime)); isc_time_formatISO8601ms(&named_g_boottime, boottime, sizeof(boottime));
isc_time_formatISO8601ms(&named_g_configtime, configtime, isc_time_formatISO8601ms(&named_g_configtime, configtime,
sizeof configtime); sizeof configtime);

View File

@ -1954,11 +1954,8 @@ isc_result_t
named_zone_configure_writeable_dlz(dns_dlzdb_t *dlzdatabase, dns_zone_t *zone, named_zone_configure_writeable_dlz(dns_dlzdb_t *dlzdatabase, dns_zone_t *zone,
dns_rdataclass_t rdclass, dns_name_t *name) { dns_rdataclass_t rdclass, dns_name_t *name) {
dns_db_t *db = NULL; dns_db_t *db = NULL;
isc_time_t now;
isc_result_t result; isc_result_t result;
TIME_NOW(&now);
dns_zone_settype(zone, dns_zone_dlz); dns_zone_settype(zone, dns_zone_dlz);
result = dns_sdlz_setdb(dlzdatabase, rdclass, name, &db); result = dns_sdlz_setdb(dlzdatabase, rdclass, name, &db);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {

View File

@ -2150,13 +2150,13 @@ main(int argc, char *argv[]) {
*/ */
if (burst) { if (burst) {
isc_time_t start, now; isc_time_t start, now;
RUNCHECK(isc_time_now(&start)); start = isc_time_now();
/* /*
* Sleep to 1ms of the end of the second then run a busy loop * Sleep to 1ms of the end of the second then run a busy loop
* until the second changes. * until the second changes.
*/ */
do { do {
RUNCHECK(isc_time_now(&now)); now = isc_time_now();
if (isc_time_seconds(&start) == isc_time_seconds(&now)) if (isc_time_seconds(&start) == isc_time_seconds(&now))
{ {
int us = US_PER_SEC - int us = US_PER_SEC -

75
cocci/isc_time_now.spatch Normal file
View File

@ -0,0 +1,75 @@
@@
statement S;
expression V, E;
@@
- V = isc_time_now(&E);
- if (V != ISC_R_SUCCESS) S
+ E = isc_time_now();
@@
expression V, E;
@@
- V = isc_time_now(&E);
- RUNTIME_CHECK(V == ISC_R_SUCCESS);
+ E = isc_time_now();
@@
expression V, E;
@@
- V = isc_time_now(&E);
- assert_int_equal(V, ISC_R_SUCCESS);
+ E = isc_time_now();
@@
expression E;
@@
- assert_int_equal(isc_time_now(&E), ISC_R_SUCCESS);
+ E = isc_time_now();
@@
expression E;
@@
- TIME_NOW(&E);
+ E = isc_time_now();
@@
expression E;
@@
- CHECK(isc_time_now(&E));
+ E = isc_time_now();
@@
statement S;
expression V, E;
@@
- V = isc_time_now_hires(&E);
- if (V != ISC_R_SUCCESS) S
+ E = isc_time_now_hires();
@@
expression E;
@@
- isc_time_now(&E);
+ E = isc_time_now();
@@
expression E;
@@
- isc_time_now_hires(&E);
+ E = isc_time_now_hires();
@@
expression E;
@@
- TIME_NOW_HIRES(&E);
+ E = isc_time_now_hires();

View File

@ -212,7 +212,6 @@ void
dns_badcache_add(dns_badcache_t *bc, const dns_name_t *name, dns_badcache_add(dns_badcache_t *bc, const dns_name_t *name,
dns_rdatatype_t type, bool update, uint32_t flags, dns_rdatatype_t type, bool update, uint32_t flags,
isc_time_t *expire) { isc_time_t *expire) {
isc_result_t result;
unsigned int hashval, hash; unsigned int hashval, hash;
dns_bcentry_t *bad, *prev, *next; dns_bcentry_t *bad, *prev, *next;
isc_time_t now; isc_time_t now;
@ -224,10 +223,7 @@ dns_badcache_add(dns_badcache_t *bc, const dns_name_t *name,
RWLOCK(&bc->lock, isc_rwlocktype_read); RWLOCK(&bc->lock, isc_rwlocktype_read);
result = isc_time_now(&now); now = isc_time_now();
if (result != ISC_R_SUCCESS) {
isc_time_settoepoch(&now);
}
hashval = dns_name_hash(name); hashval = dns_name_hash(name);
hash = hashval % bc->size; hash = hashval % bc->size;
@ -389,7 +385,6 @@ dns_badcache_flush(dns_badcache_t *bc) {
void void
dns_badcache_flushname(dns_badcache_t *bc, const dns_name_t *name) { dns_badcache_flushname(dns_badcache_t *bc, const dns_name_t *name) {
dns_bcentry_t *bad, *prev, *next; dns_bcentry_t *bad, *prev, *next;
isc_result_t result;
isc_time_t now; isc_time_t now;
unsigned int hash; unsigned int hash;
@ -398,10 +393,7 @@ dns_badcache_flushname(dns_badcache_t *bc, const dns_name_t *name) {
RWLOCK(&bc->lock, isc_rwlocktype_read); RWLOCK(&bc->lock, isc_rwlocktype_read);
result = isc_time_now(&now); now = isc_time_now();
if (result != ISC_R_SUCCESS) {
isc_time_settoepoch(&now);
}
hash = dns_name_hash(name) % bc->size; hash = dns_name_hash(name) % bc->size;
LOCK(&bc->tlocks[hash]); LOCK(&bc->tlocks[hash]);
prev = NULL; prev = NULL;
@ -433,7 +425,6 @@ dns_badcache_flushtree(dns_badcache_t *bc, const dns_name_t *name) {
unsigned int i; unsigned int i;
int n; int n;
isc_time_t now; isc_time_t now;
isc_result_t result;
REQUIRE(VALID_BADCACHE(bc)); REQUIRE(VALID_BADCACHE(bc));
REQUIRE(name != NULL); REQUIRE(name != NULL);
@ -444,10 +435,7 @@ dns_badcache_flushtree(dns_badcache_t *bc, const dns_name_t *name) {
*/ */
RWLOCK(&bc->lock, isc_rwlocktype_write); RWLOCK(&bc->lock, isc_rwlocktype_write);
result = isc_time_now(&now); now = isc_time_now();
if (result != ISC_R_SUCCESS) {
isc_time_settoepoch(&now);
}
for (i = 0; atomic_load_relaxed(&bc->count) > 0 && i < bc->size; i++) { for (i = 0; atomic_load_relaxed(&bc->count) > 0 && i < bc->size; i++) {
prev = NULL; prev = NULL;
@ -492,7 +480,7 @@ dns_badcache_print(dns_badcache_t *bc, const char *cachename, FILE *fp) {
RWLOCK(&bc->lock, isc_rwlocktype_write); RWLOCK(&bc->lock, isc_rwlocktype_write);
fprintf(fp, ";\n; %s\n;\n", cachename); fprintf(fp, ";\n; %s\n;\n", cachename);
TIME_NOW(&now); now = isc_time_now();
for (i = 0; atomic_load_relaxed(&bc->count) > 0 && i < bc->size; i++) { for (i = 0; atomic_load_relaxed(&bc->count) > 0 && i < bc->size; i++) {
prev = NULL; prev = NULL;
for (bad = bc->table[i]; bad != NULL; bad = next) { for (bad = bc->table[i]; bad != NULL; bad = next) {

View File

@ -843,7 +843,7 @@ dns__catz_timer_start(dns_catz_zone_t *catz) {
REQUIRE(DNS_CATZ_ZONE_VALID(catz)); REQUIRE(DNS_CATZ_ZONE_VALID(catz));
isc_time_now(&now); now = isc_time_now();
tdiff = isc_time_microdiff(&now, &catz->lastupdated) / 1000000; tdiff = isc_time_microdiff(&now, &catz->lastupdated) / 1000000;
if (tdiff < catz->defoptions.min_update_interval) { if (tdiff < catz->defoptions.min_update_interval) {
uint64_t defer = catz->defoptions.min_update_interval - tdiff; uint64_t defer = catz->defoptions.min_update_interval - tdiff;
@ -2084,7 +2084,6 @@ cleanup:
static void static void
dns__catz_timer_cb(void *arg) { dns__catz_timer_cb(void *arg) {
char domain[DNS_NAME_FORMATSIZE]; char domain[DNS_NAME_FORMATSIZE];
isc_result_t result;
dns_catz_zone_t *catz = (dns_catz_zone_t *)arg; dns_catz_zone_t *catz = (dns_catz_zone_t *)arg;
REQUIRE(DNS_CATZ_ZONE_VALID(catz)); REQUIRE(DNS_CATZ_ZONE_VALID(catz));
@ -2132,8 +2131,7 @@ exit:
isc_timer_destroy(&catz->updatetimer); isc_timer_destroy(&catz->updatetimer);
catz->loop = NULL; catz->loop = NULL;
result = isc_time_now(&catz->lastupdated); catz->lastupdated = isc_time_now();
RUNTIME_CHECK(result == ISC_R_SUCCESS);
UNLOCK(&catz->catzs->lock); UNLOCK(&catz->catzs->lock);
} }

View File

@ -501,7 +501,7 @@ dispentry_runtime(dns_dispentry_t *resp) {
return (0); return (0);
} }
TIME_NOW(&now); now = isc_time_now();
return (isc_time_microdiff(&now, &resp->start) / 1000); return (isc_time_microdiff(&now, &resp->start) / 1000);
} }
@ -1804,7 +1804,7 @@ static void
udp_startrecv(isc_nmhandle_t *handle, dns_dispentry_t *resp) { udp_startrecv(isc_nmhandle_t *handle, dns_dispentry_t *resp) {
REQUIRE(VALID_RESPONSE(resp)); REQUIRE(VALID_RESPONSE(resp));
TIME_NOW(&resp->start); resp->start = isc_time_now();
dispentry_log(resp, LVL(90), "attaching handle %p to %p", handle, dispentry_log(resp, LVL(90), "attaching handle %p to %p", handle,
&resp->handle); &resp->handle);
isc_nmhandle_attach(handle, &resp->handle); isc_nmhandle_attach(handle, &resp->handle);

View File

@ -753,7 +753,7 @@ dns_dt_send(dns_view_t *view, dns_dtmsgtype_t msgtype, isc_sockaddr_t *qaddr,
check_file_size_and_maybe_reopen(view->dtenv); check_file_size_and_maybe_reopen(view->dtenv);
} }
TIME_NOW(&now); now = isc_time_now();
t = &now; t = &now;
init_msg(view->dtenv, &dm, dnstap_type(msgtype)); init_msg(view->dtenv, &dm, dnstap_type(msgtype));

View File

@ -985,7 +985,7 @@ adjust_quantum(unsigned int old, isc_time_t *start) {
if (pps < 100) { if (pps < 100) {
pps = 100; pps = 100;
} }
isc_time_now(&end); end = isc_time_now();
interval = 1000000 / pps; /* interval in usec */ interval = 1000000 / pps; /* interval in usec */
if (interval == 0) { if (interval == 0) {
@ -1082,7 +1082,7 @@ free_rbtdb(dns_rbtdb_t *rbtdb, bool log) {
} }
} }
isc_time_now(&start); start = isc_time_now();
result = dns_rbt_destroy2(treep, rbtdb->quantum); result = dns_rbt_destroy2(treep, rbtdb->quantum);
if (result == ISC_R_QUOTA) { if (result == ISC_R_QUOTA) {
INSIST(rbtdb->loop != NULL); INSIST(rbtdb->loop != NULL);

View File

@ -1071,7 +1071,7 @@ fctx_starttimer(fetchctx_t *fctx) {
isc_interval_set(&interval, 2, 0); isc_interval_set(&interval, 2, 0);
isc_time_add(&fctx->expires, &interval, &expires); isc_time_add(&fctx->expires, &interval, &expires);
isc_time_now(&now); now = isc_time_now();
if (isc_time_compare(&expires, &now) <= 0) { if (isc_time_compare(&expires, &now) <= 0) {
isc_interval_set(&interval, 0, 1); isc_interval_set(&interval, 0, 1);
} else { } else {
@ -1547,7 +1547,7 @@ fctx_sendevents(fetchctx_t *fctx, isc_result_t result) {
* Keep some record of fetch result for logging later (if required). * Keep some record of fetch result for logging later (if required).
*/ */
fctx->result = result; fctx->result = result;
TIME_NOW(&now); now = isc_time_now();
fctx->duration = isc_time_microdiff(&now, &fctx->start); fctx->duration = isc_time_microdiff(&now, &fctx->start);
for (resp = ISC_LIST_HEAD(fctx->resps); resp != NULL; resp = next) { for (resp = ISC_LIST_HEAD(fctx->resps); resp != NULL; resp = next) {
@ -1802,7 +1802,7 @@ fctx_setretryinterval(fetchctx_t *fctx, unsigned int rtt) {
/* /*
* Has this fetch already expired? * Has this fetch already expired?
*/ */
isc_time_now(&now); now = isc_time_now();
limit = isc_time_microdiff(&fctx->expires, &now); limit = isc_time_microdiff(&fctx->expires, &now);
if (limit < US_PER_MS) { if (limit < US_PER_MS) {
FCTXTRACE("fetch already expired"); FCTXTRACE("fetch already expired");
@ -1888,7 +1888,7 @@ resquery_timeout(resquery_t *query) {
* (Note that netmgr timeouts have millisecond accuracy, so * (Note that netmgr timeouts have millisecond accuracy, so
* anything less than 1000 microseconds is close enough to zero.) * anything less than 1000 microseconds is close enough to zero.)
*/ */
isc_time_now(&now); now = isc_time_now();
timeleft = isc_time_microdiff(&fctx->expires_try_stale, &now); timeleft = isc_time_microdiff(&fctx->expires_try_stale, &now);
if (timeleft >= US_PER_MS) { if (timeleft >= US_PER_MS) {
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
@ -1999,7 +1999,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
dns_message_create(fctx->mctx, DNS_MESSAGE_INTENTPARSE, dns_message_create(fctx->mctx, DNS_MESSAGE_INTENTPARSE,
&query->rmessage); &query->rmessage);
TIME_NOW(&query->start); query->start = isc_time_now();
/* /*
* If this is a TCP query, then we need to make a socket and * If this is a TCP query, then we need to make a socket and
@ -4533,7 +4533,7 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type,
dns_rdataset_init(&fctx->qminrrset); dns_rdataset_init(&fctx->qminrrset);
dns_rdataset_init(&fctx->nsrrset); dns_rdataset_init(&fctx->nsrrset);
TIME_NOW(&fctx->start); fctx->start = isc_time_now();
fctx->now = (isc_stdtime_t)fctx->start.seconds; fctx->now = (isc_stdtime_t)fctx->start.seconds;
if (client != NULL) { if (client != NULL) {
@ -7711,7 +7711,7 @@ rctx_respinit(resquery_t *query, fetchctx_t *fctx, isc_result_t result,
} else { } else {
isc_buffer_initnull(&rctx->buffer); isc_buffer_initnull(&rctx->buffer);
} }
TIME_NOW(&rctx->tnow); rctx->tnow = isc_time_now();
rctx->finish = &rctx->tnow; rctx->finish = &rctx->tnow;
rctx->now = (isc_stdtime_t)isc_time_seconds(&rctx->tnow); rctx->now = (isc_stdtime_t)isc_time_seconds(&rctx->tnow);
} }
@ -7832,7 +7832,7 @@ rctx_timedout(respctx_t *rctx) {
fctx->timeout = true; fctx->timeout = true;
fctx->timeouts++; fctx->timeouts++;
isc_time_now(&now); now = isc_time_now();
/* netmgr timeouts are accurate to the millisecond */ /* netmgr timeouts are accurate to the millisecond */
if (isc_time_microdiff(&fctx->expires, &now) < US_PER_MS) { if (isc_time_microdiff(&fctx->expires, &now) < US_PER_MS) {
FCTXTRACE("query timed out; stopped trying to make " FCTXTRACE("query timed out; stopped trying to make "

View File

@ -1632,7 +1632,7 @@ dns__rpz_timer_start(dns_rpz_zone_t *rpz) {
REQUIRE(DNS_RPZ_ZONE_VALID(rpz)); REQUIRE(DNS_RPZ_ZONE_VALID(rpz));
isc_time_now(&now); now = isc_time_now();
tdiff = isc_time_microdiff(&now, &rpz->lastupdated) / 1000000; tdiff = isc_time_microdiff(&now, &rpz->lastupdated) / 1000000;
if (tdiff < rpz->min_update_interval) { if (tdiff < rpz->min_update_interval) {
uint64_t defer = rpz->min_update_interval - tdiff; uint64_t defer = rpz->min_update_interval - tdiff;
@ -1934,7 +1934,6 @@ shuttingdown:
static void static void
dns__rpz_timer_cb(void *arg) { dns__rpz_timer_cb(void *arg) {
char domain[DNS_NAME_FORMATSIZE]; char domain[DNS_NAME_FORMATSIZE];
isc_result_t result;
dns_rpz_zone_t *rpz = (dns_rpz_zone_t *)arg; dns_rpz_zone_t *rpz = (dns_rpz_zone_t *)arg;
REQUIRE(DNS_RPZ_ZONE_VALID(rpz)); REQUIRE(DNS_RPZ_ZONE_VALID(rpz));
@ -1967,8 +1966,7 @@ dns__rpz_timer_cb(void *arg) {
isc_timer_destroy(&rpz->updatetimer); isc_timer_destroy(&rpz->updatetimer);
rpz->loop = NULL; rpz->loop = NULL;
result = isc_time_now(&rpz->lastupdated); rpz->lastupdated = isc_time_now();
RUNTIME_CHECK(result == ISC_R_SUCCESS);
unlock: unlock:
UNLOCK(&rpz->rpzs->maint_lock); UNLOCK(&rpz->rpzs->maint_lock);
} }

View File

@ -851,15 +851,13 @@ view_find(dns_validator_t *val, dns_name_t *name, dns_rdatatype_t type) {
dns_name_t *foundname; dns_name_t *foundname;
isc_result_t result; isc_result_t result;
unsigned int options; unsigned int options;
isc_time_t now; isc_time_t now = isc_time_now();
char namebuf[DNS_NAME_FORMATSIZE]; char namebuf[DNS_NAME_FORMATSIZE];
char typebuf[DNS_RDATATYPE_FORMATSIZE]; char typebuf[DNS_RDATATYPE_FORMATSIZE];
disassociate_rdatasets(val); disassociate_rdatasets(val);
if (isc_time_now(&now) == ISC_R_SUCCESS && if (dns_resolver_getbadcache(val->view->resolver, name, type, &now)) {
dns_resolver_getbadcache(val->view->resolver, name, type, &now))
{
dns_name_format(name, namebuf, sizeof(namebuf)); dns_name_format(name, namebuf, sizeof(namebuf));
dns_rdatatype_format(type, typebuf, sizeof(typebuf)); dns_rdatatype_format(type, typebuf, sizeof(typebuf));
validator_log(val, ISC_LOG_INFO, "bad cache hit (%s/%s)", validator_log(val, ISC_LOG_INFO, "bad cache hit (%s/%s)",

View File

@ -859,7 +859,7 @@ xfrin_create(isc_mem_t *mctx, dns_zone_t *zone, dns_db_t *db,
xfr->state = XFRST_INITIALSOA; xfr->state = XFRST_INITIALSOA;
} }
isc_time_now(&xfr->start); xfr->start = isc_time_now();
if (tsigkey != NULL) { if (tsigkey != NULL) {
dns_tsigkey_attach(tsigkey, &xfr->tsigkey); dns_tsigkey_attach(tsigkey, &xfr->tsigkey);
@ -990,7 +990,7 @@ xfrin_connect_done(isc_result_t result, isc_region_t *region, void *arg) {
zmgr = dns_zone_getmgr(xfr->zone); zmgr = dns_zone_getmgr(xfr->zone);
if (zmgr != NULL) { if (zmgr != NULL) {
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
TIME_NOW(&now); now = isc_time_now();
dns_zonemgr_unreachableadd(zmgr, &xfr->primaryaddr, dns_zonemgr_unreachableadd(zmgr, &xfr->primaryaddr,
&xfr->sourceaddr, &now); &xfr->sourceaddr, &now);
CHECK(result); CHECK(result);
@ -1119,7 +1119,7 @@ xfrin_send_request(dns_xfrin_t *xfr) {
xfr->nmsg = 0; xfr->nmsg = 0;
xfr->nrecs = 0; xfr->nrecs = 0;
xfr->nbytes = 0; xfr->nbytes = 0;
isc_time_now(&xfr->start); xfr->start = isc_time_now();
msg->id = xfr->id; msg->id = xfr->id;
if (xfr->tsigctx != NULL) { if (xfr->tsigctx != NULL) {
dst_context_destroy(&xfr->tsigctx); dst_context_destroy(&xfr->tsigctx);
@ -1494,7 +1494,7 @@ xfrin_destroy(dns_xfrin_t *xfr) {
* Calculate the length of time the transfer took, * Calculate the length of time the transfer took,
* and print a log message with the bytes and rate. * and print a log message with the bytes and rate.
*/ */
isc_time_now(&xfr->end); xfr->end = isc_time_now();
msecs = isc_time_microdiff(&xfr->end, &xfr->start) / 1000; msecs = isc_time_microdiff(&xfr->end, &xfr->start) / 1000;
if (msecs == 0) { if (msecs == 0) {
msecs = 1; msecs = 1;

View File

@ -1054,7 +1054,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid) {
REQUIRE(zonep != NULL && *zonep == NULL); REQUIRE(zonep != NULL && *zonep == NULL);
REQUIRE(mctx != NULL); REQUIRE(mctx != NULL);
TIME_NOW(&now); now = isc_time_now();
zone = isc_mem_get(mctx, sizeof(*zone)); zone = isc_mem_get(mctx, sizeof(*zone));
*zone = (dns_zone_t){ *zone = (dns_zone_t){
.masterformat = dns_masterformat_none, .masterformat = dns_masterformat_none,
@ -2061,7 +2061,7 @@ zone_load(dns_zone_t *zone, unsigned int flags, bool locked) {
LOCK_ZONE(zone->raw); LOCK_ZONE(zone->raw);
} }
TIME_NOW(&now); now = isc_time_now();
INSIST(zone->type != dns_zone_none); INSIST(zone->type != dns_zone_none);
@ -2106,7 +2106,7 @@ zone_load(dns_zone_t *zone, unsigned int flags, bool locked) {
* zone->loadtime is set, then the file will still be reloaded * zone->loadtime is set, then the file will still be reloaded
* the next time dns_zone_load is called. * the next time dns_zone_load is called.
*/ */
TIME_NOW(&loadtime); loadtime = isc_time_now();
/* /*
* Don't do the load if the file that stores the zone is older * Don't do the load if the file that stores the zone is older
@ -3648,7 +3648,7 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) {
ISC_LIST_INITANDAPPEND(zone->nsec3chain, nsec3chain, link); ISC_LIST_INITANDAPPEND(zone->nsec3chain, nsec3chain, link);
nsec3chain = NULL; nsec3chain = NULL;
if (isc_time_isepoch(&zone->nsec3chaintime)) { if (isc_time_isepoch(&zone->nsec3chaintime)) {
TIME_NOW(&now); now = isc_time_now();
zone->nsec3chaintime = now; zone->nsec3chaintime = now;
if (zone->loop != NULL) { if (zone->loop != NULL) {
zone_settimer(zone, &now); zone_settimer(zone, &now);
@ -3968,7 +3968,7 @@ set_refreshkeytimer(dns_zone_t *zone, dns_rdata_keydata_t *key,
then = key->removehd; then = key->removehd;
} }
TIME_NOW(&timenow); timenow = isc_time_now();
if (then > now) { if (then > now) {
DNS_ZONE_TIME_ADD(&timenow, then - now, &timethen); DNS_ZONE_TIME_ADD(&timenow, then - now, &timethen);
} else { } else {
@ -4720,7 +4720,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
INSIST(LOCKED_ZONE(zone->secure)); INSIST(LOCKED_ZONE(zone->secure));
} }
TIME_NOW(&now); now = isc_time_now();
/* /*
* Initiate zone transfer? We may need a error code that * Initiate zone transfer? We may need a error code that
@ -10661,7 +10661,7 @@ retry_keyfetch(dns_keyfetch_t *kfetch, dns_name_t *kname) {
/* Don't really retry if we are exiting */ /* Don't really retry if we are exiting */
char timebuf[80]; char timebuf[80];
TIME_NOW(&timenow); timenow = isc_time_now();
DNS_ZONE_TIME_ADD(&timenow, dns_zone_mkey_hour, &timethen); DNS_ZONE_TIME_ADD(&timenow, dns_zone_mkey_hour, &timethen);
zone->refreshkeytime = timethen; zone->refreshkeytime = timethen;
zone_settimer(zone, &timenow); zone_settimer(zone, &timenow);
@ -10907,7 +10907,7 @@ zone_maintenance(dns_zone_t *zone) {
return; return;
} }
TIME_NOW(&now); now = isc_time_now();
/* /*
* Expire check. * Expire check.
@ -11154,7 +11154,7 @@ again:
set_resigntime(zone); set_resigntime(zone);
if (zone->loop != NULL) { if (zone->loop != NULL) {
isc_time_t now; isc_time_t now;
TIME_NOW(&now); now = isc_time_now();
zone_settimer(zone, &now); zone_settimer(zone, &now);
} }
} }
@ -11481,7 +11481,7 @@ zone_needdump(dns_zone_t *zone, unsigned int delay) {
return; return;
} }
TIME_NOW(&now); now = isc_time_now();
/* add some noise */ /* add some noise */
DNS_ZONE_JITTER_ADD(&now, delay, &dumptime); DNS_ZONE_JITTER_ADD(&now, delay, &dumptime);
@ -12383,7 +12383,7 @@ dns_zone_notify(dns_zone_t *zone) {
LOCK_ZONE(zone); LOCK_ZONE(zone);
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY); DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY);
TIME_NOW(&now); now = isc_time_now();
zone_settimer(zone, &now); zone_settimer(zone, &now);
UNLOCK_ZONE(zone); UNLOCK_ZONE(zone);
} }
@ -12790,7 +12790,7 @@ stub_glue_response(void *arg) {
ENTER; ENTER;
TIME_NOW(&now); now = isc_time_now();
LOCK_ZONE(zone); LOCK_ZONE(zone);
@ -13206,7 +13206,7 @@ stub_callback(void *arg) {
ENTER; ENTER;
TIME_NOW(&now); now = isc_time_now();
LOCK_ZONE(zone); LOCK_ZONE(zone);
@ -13540,7 +13540,7 @@ refresh_callback(void *arg) {
ENTER; ENTER;
TIME_NOW(&now); now = isc_time_now();
LOCK_ZONE(zone); LOCK_ZONE(zone);
@ -14809,7 +14809,7 @@ cancel_refresh(dns_zone_t *zone) {
ENTER; ENTER;
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH); DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH);
TIME_NOW(&now); now = isc_time_now();
zone_settimer(zone, &now); zone_settimer(zone, &now);
} }
@ -16149,7 +16149,7 @@ receive_secure_serial(void *arg) {
* signature expiration. * signature expiration.
*/ */
set_resigntime(zone); set_resigntime(zone);
TIME_NOW(&timenow); timenow = isc_time_now();
zone_settimer(zone, &timenow); zone_settimer(zone, &timenow);
UNLOCK_ZONE(zone); UNLOCK_ZONE(zone);
@ -16171,7 +16171,7 @@ failure:
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
LOCK_ZONE(zone); LOCK_ZONE(zone);
set_resigntime(zone); set_resigntime(zone);
TIME_NOW(&timenow); timenow = isc_time_now();
zone_settimer(zone, &timenow); zone_settimer(zone, &timenow);
UNLOCK_ZONE(zone); UNLOCK_ZONE(zone);
if (result == DNS_R_UNCHANGED) { if (result == DNS_R_UNCHANGED) {
@ -16577,7 +16577,7 @@ receive_secure_db(void *arg) {
goto failure; goto failure;
} }
TIME_NOW(&loadtime); loadtime = isc_time_now();
ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read); ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read);
if (zone->db != NULL) { if (zone->db != NULL) {
result = dns_db_getsoaserial(zone->db, NULL, &oldserial); result = dns_db_getsoaserial(zone->db, NULL, &oldserial);
@ -16977,7 +16977,7 @@ again:
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH); DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH);
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_SOABEFOREAXFR); DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_SOABEFOREAXFR);
TIME_NOW(&now); now = isc_time_now();
switch (xfrresult) { switch (xfrresult) {
case ISC_R_SUCCESS: case ISC_R_SUCCESS:
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY); DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY);
@ -17351,7 +17351,7 @@ dns_zone_setsigresigninginterval(dns_zone_t *zone, uint32_t interval) {
zone->sigresigninginterval = interval; zone->sigresigninginterval = interval;
set_resigntime(zone); set_resigntime(zone);
if (zone->loop != NULL) { if (zone->loop != NULL) {
TIME_NOW(&now); now = isc_time_now();
zone_settimer(zone, &now); zone_settimer(zone, &now);
} }
UNLOCK_ZONE(zone); UNLOCK_ZONE(zone);
@ -17414,7 +17414,7 @@ got_transfer_quota(void *arg) {
CHECK(ISC_R_CANCELED); CHECK(ISC_R_CANCELED);
} }
TIME_NOW(&now); now = isc_time_now();
primaryaddr = dns_remote_curraddr(&zone->primaries); primaryaddr = dns_remote_curraddr(&zone->primaries);
isc_sockaddr_format(&primaryaddr, primary, sizeof(primary)); isc_sockaddr_format(&primaryaddr, primary, sizeof(primary));
@ -18179,7 +18179,7 @@ dns_zonemgr_forcemaint(dns_zonemgr_t *zmgr) {
isc_time_t now; isc_time_t now;
LOCK_ZONE(zone); LOCK_ZONE(zone);
TIME_NOW(&now); now = isc_time_now();
zone_settimer(zone, &now); zone_settimer(zone, &now);
UNLOCK_ZONE(zone); UNLOCK_ZONE(zone);
} }
@ -19152,7 +19152,7 @@ zone_signwithkey(dns_zone_t *zone, dns_secalg_t algorithm, uint16_t keyid,
signing->deleteit = deleteit; signing->deleteit = deleteit;
signing->done = false; signing->done = false;
TIME_NOW(&now); now = isc_time_now();
ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read); ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read);
if (zone->db != NULL) { if (zone->db != NULL) {
@ -19806,7 +19806,7 @@ checkds_done(void *arg) {
"checkds: empty DS response from %s", addrbuf); "checkds: empty DS response from %s", addrbuf);
} }
TIME_NOW(&timenow); timenow = isc_time_now();
now = isc_time_seconds(&timenow); now = isc_time_seconds(&timenow);
CHECK(dns_zone_getdb(zone, &db)); CHECK(dns_zone_getdb(zone, &db));
@ -20355,7 +20355,7 @@ zone_rekey(dns_zone_t *zone) {
CHECK(dns_db_newversion(db, &ver)); CHECK(dns_db_newversion(db, &ver));
CHECK(dns_db_getoriginnode(db, &node)); CHECK(dns_db_getoriginnode(db, &node));
TIME_NOW(&timenow); timenow = isc_time_now();
now = isc_time_seconds(&timenow); now = isc_time_seconds(&timenow);
kasp = dns_zone_getkasp(zone); kasp = dns_zone_getkasp(zone);
@ -20972,7 +20972,7 @@ dns_zone_rekey(dns_zone_t *zone, bool fullsign) {
DNS_ZONEKEY_SETOPTION(zone, DNS_ZONEKEY_FULLSIGN); DNS_ZONEKEY_SETOPTION(zone, DNS_ZONEKEY_FULLSIGN);
} }
TIME_NOW(&now); now = isc_time_now();
zone->refreshkeytime = now; zone->refreshkeytime = now;
zone_settimer(zone, &now); zone_settimer(zone, &now);
@ -21242,7 +21242,7 @@ dns_zone_dlzpostload(dns_zone_t *zone, dns_db_t *db) {
isc_result_t result; isc_result_t result;
dns_zone_t *secure = NULL; dns_zone_t *secure = NULL;
TIME_NOW(&loadtime); loadtime = isc_time_now();
/* /*
* Lock hierarchy: zmgr, zone, raw. * Lock hierarchy: zmgr, zone, raw.

View File

@ -762,7 +762,7 @@ prepare_response(isc_httpdmgr_t *mgr, isc_httpd_t *httpd,
REQUIRE(VALID_HTTPD(httpd)); REQUIRE(VALID_HTTPD(httpd));
REQUIRE(reqp != NULL && *reqp == NULL); REQUIRE(reqp != NULL && *reqp == NULL);
isc_time_now(&now); now = isc_time_now();
isc_time_formathttptimestamp(&now, datebuf, sizeof(datebuf)); isc_time_formathttptimestamp(&now, datebuf, sizeof(datebuf));
if (httpd->up.field_set & (1 << ISC_UF_PATH)) { if (httpd->up.field_set & (1 << ISC_UF_PATH)) {
@ -1080,7 +1080,7 @@ isc_httpdmgr_addurl(isc_httpdmgr_t *httpdmgr, const char *url, bool isstatic,
item->action = func; item->action = func;
item->action_arg = arg; item->action_arg = arg;
item->isstatic = isstatic; item->isstatic = isstatic;
isc_time_now(&item->loadtime); item->loadtime = isc_time_now();
ISC_LINK_INIT(item, link); ISC_LINK_INIT(item, link);

View File

@ -166,8 +166,8 @@ isc_time_monotonic(void);
* Returns the system's monotonic time in linear nanoseconds. * Returns the system's monotonic time in linear nanoseconds.
*/ */
isc_result_t isc_time_t
isc_time_now(isc_time_t *t); isc_time_now(void);
/*%< /*%<
* Set 't' to the current absolute time. * Set 't' to the current absolute time.
* *
@ -185,8 +185,8 @@ isc_time_now(isc_time_t *t);
* in the current definition of isc_time_t. * in the current definition of isc_time_t.
*/ */
isc_result_t isc_time_t
isc_time_now_hires(isc_time_t *t); isc_time_now_hires(void);
/*%< /*%<
* Set 't' to the current absolute time. Uses higher resolution clocks * Set 't' to the current absolute time. Uses higher resolution clocks
* recommended when microsecond accuracy is required. * recommended when microsecond accuracy is required.

View File

@ -357,13 +357,6 @@ mock_assert(const int result, const char *const expression,
FATAL_SYSERROR(ret, "%s()", #func); \ FATAL_SYSERROR(ret, "%s()", #func); \
} }
/*%
* Time
*/
#define TIME_NOW(tp) RUNTIME_CHECK(isc_time_now((tp)) == ISC_R_SUCCESS)
#define TIME_NOW_HIRES(tp) \
RUNTIME_CHECK(isc_time_now_hires((tp)) == ISC_R_SUCCESS)
/*% /*%
* Alignment * Alignment
*/ */

View File

@ -1324,7 +1324,7 @@ roll_timestamp(isc_logfile_t *file) {
} }
/* Then just rename the current logfile */ /* Then just rename the current logfile */
isc_time_now(&now); now = isc_time_now();
isc_time_formatshorttimestamp(&now, newts, PATH_MAX + 1); isc_time_formatshorttimestamp(&now, newts, PATH_MAX + 1);
n = snprintf(newpath, sizeof(newpath), "%s.%s", path, newts); n = snprintf(newpath, sizeof(newpath), "%s.%s", path, newts);
if (n >= (int)sizeof(newpath) || n < 0) { if (n >= (int)sizeof(newpath) || n < 0) {
@ -1590,7 +1590,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
{ {
isc_time_t isctime; isc_time_t isctime;
TIME_NOW(&isctime); isctime = isc_time_now();
isc_time_formattimestamp(&isctime, local_time, isc_time_formattimestamp(&isctime, local_time,
sizeof(local_time)); sizeof(local_time));
@ -1640,7 +1640,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
* messages which fall within the * messages which fall within the
* duplicate_interval range. * duplicate_interval range.
*/ */
TIME_NOW(&oldest); oldest = isc_time_now();
if (isc_time_subtract(&oldest, &interval, if (isc_time_subtract(&oldest, &interval,
&oldest) != ISC_R_SUCCESS) &oldest) != ISC_R_SUCCESS)
{ {
@ -1718,7 +1718,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
message->text = (char *)(message + 1); message->text = (char *)(message + 1);
size -= sizeof(isc_logmessage_t); size -= sizeof(isc_logmessage_t);
strlcpy(message->text, lctx->buffer, size); strlcpy(message->text, lctx->buffer, size);
TIME_NOW(&message->time); message->time = isc_time_now();
ISC_LINK_INIT(message, link); ISC_LINK_INIT(message, link);
ISC_LIST_APPEND(lctx->messages, message, link); ISC_LIST_APPEND(lctx->messages, message, link);
} }

View File

@ -79,44 +79,34 @@ isc_time_isepoch(const isc_time_t *t) {
return (false); return (false);
} }
static isc_result_t static isc_time_t
time_now(isc_time_t *t, clockid_t clock) { time_now(clockid_t clock) {
isc_time_t t;
struct timespec ts; struct timespec ts;
REQUIRE(t != NULL); RUNTIME_CHECK(clock_gettime(clock, &ts) == 0);
INSIST(ts.tv_sec >= 0 && ts.tv_nsec >= 0 && ts.tv_nsec < NS_PER_SEC);
if (clock_gettime(clock, &ts) == -1) {
UNEXPECTED_SYSERROR(errno, "clock_gettime()");
return (ISC_R_UNEXPECTED);
}
if (ts.tv_sec < 0 || ts.tv_nsec < 0 || ts.tv_nsec >= NS_PER_SEC) {
return (ISC_R_UNEXPECTED);
}
/* /*
* Ensure the tv_sec value fits in t->seconds. * Ensure the tv_sec value fits in t->seconds.
*/ */
if (sizeof(ts.tv_sec) > sizeof(t->seconds) && INSIST(sizeof(ts.tv_sec) <= sizeof(t.seconds) ||
((ts.tv_sec | (unsigned int)-1) ^ (unsigned int)-1) != 0U) ((ts.tv_sec | (unsigned int)-1) ^ (unsigned int)-1) == 0U);
{
return (ISC_R_RANGE);
}
t->seconds = ts.tv_sec; t.seconds = ts.tv_sec;
t->nanoseconds = ts.tv_nsec; t.nanoseconds = ts.tv_nsec;
return (ISC_R_SUCCESS); return (t);
} }
isc_result_t isc_time_t
isc_time_now_hires(isc_time_t *t) { isc_time_now_hires(void) {
return time_now(t, CLOCKSOURCE_HIRES); return (time_now(CLOCKSOURCE_HIRES));
} }
isc_result_t isc_time_t
isc_time_now(isc_time_t *t) { isc_time_now(void) {
return time_now(t, CLOCKSOURCE); return (time_now(CLOCKSOURCE));
} }
isc_nanosecs_t isc_nanosecs_t

View File

@ -1779,7 +1779,7 @@ ns_client_request(isc_nmhandle_t *handle, isc_result_t eresult,
client->state = NS_CLIENTSTATE_WORKING; client->state = NS_CLIENTSTATE_WORKING;
TIME_NOW(&client->requesttime); client->requesttime = isc_time_now();
client->tnow = client->requesttime; client->tnow = client->requesttime;
client->now = isc_time_seconds(&client->tnow); client->now = isc_time_seconds(&client->tnow);

View File

@ -1248,7 +1248,7 @@ xfrout_ctx_create(isc_mem_t *mctx, ns_client_t *client, unsigned int id,
dns_db_attach(db, &xfr->db); dns_db_attach(db, &xfr->db);
dns_db_attachversion(db, ver, &xfr->ver); dns_db_attachversion(db, ver, &xfr->ver);
isc_time_now(&xfr->stats.start); xfr->stats.start = isc_time_now();
isc_nm_timer_create(xfr->client->handle, xfrout_client_timeout, xfr, isc_nm_timer_create(xfr->client->handle, xfrout_client_timeout, xfr,
&xfr->maxtime_timer); &xfr->maxtime_timer);
@ -1659,7 +1659,7 @@ xfrout_senddone(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
uint64_t msecs, persec; uint64_t msecs, persec;
inc_stats(xfr->client, xfr->zone, ns_statscounter_xfrdone); inc_stats(xfr->client, xfr->zone, ns_statscounter_xfrdone);
isc_time_now(&xfr->stats.end); xfr->stats.end = isc_time_now();
msecs = isc_time_microdiff(&xfr->stats.end, &xfr->stats.start); msecs = isc_time_microdiff(&xfr->stats.end, &xfr->stats.start);
msecs /= 1000; msecs /= 1000;
if (msecs == 0) { if (msecs == 0) {

View File

@ -28,12 +28,12 @@ copy_fn(void *a, void *b, unsigned int len);
static void static void
time_it(copy_fn *copier, void *a, void *b, const char *name) { time_it(copy_fn *copier, void *a, void *b, const char *name) {
isc_time_t start; isc_time_t start;
isc_time_now_hires(&start); start = isc_time_now_hires();
copier(a, b, SIZE); copier(a, b, SIZE);
isc_time_t finish; isc_time_t finish;
isc_time_now_hires(&finish); finish = isc_time_now_hires();
uint64_t microseconds = isc_time_microdiff(&finish, &start); uint64_t microseconds = isc_time_microdiff(&finish, &start);
printf("%f for %s\n", (double)microseconds / 1000000.0, name); printf("%f for %s\n", (double)microseconds / 1000000.0, name);

View File

@ -67,7 +67,7 @@ main(void) {
unsigned int repeat = 100; unsigned int repeat = 100;
isc_time_t start; isc_time_t start;
isc_time_now_hires(&start); start = isc_time_now_hires();
for (unsigned int n = 0; n < repeat; n++) { for (unsigned int n = 0; n < repeat; n++) {
static uint8_t wire[4 * 1024]; static uint8_t wire[4 * 1024];
@ -91,7 +91,7 @@ main(void) {
} }
isc_time_t finish; isc_time_t finish;
isc_time_now_hires(&finish); finish = isc_time_now_hires();
uint64_t microseconds = isc_time_microdiff(&finish, &start); uint64_t microseconds = isc_time_microdiff(&finish, &start);
printf("time %f / %u\n", (double)microseconds / 1000000.0, repeat); printf("time %f / %u\n", (double)microseconds / 1000000.0, repeat);

View File

@ -76,13 +76,13 @@ new_bench(const uint8_t *data, size_t size) {
static void static void
oldnew_bench(const uint8_t *data, size_t size) { oldnew_bench(const uint8_t *data, size_t size) {
isc_time_t t0; isc_time_t t0;
isc_time_now_hires(&t0); t0 = isc_time_now_hires();
uint32_t n1 = old_bench(data, size); uint32_t n1 = old_bench(data, size);
isc_time_t t1; isc_time_t t1;
isc_time_now_hires(&t1); t1 = isc_time_now_hires();
uint32_t n2 = new_bench(data, size); uint32_t n2 = new_bench(data, size);
isc_time_t t2; isc_time_t t2;
isc_time_now_hires(&t2); t2 = isc_time_now_hires();
double t01 = (double)isc_time_microdiff(&t1, &t0); double t01 = (double)isc_time_microdiff(&t1, &t0);
double t12 = (double)isc_time_microdiff(&t2, &t1); double t12 = (double)isc_time_microdiff(&t2, &t1);

View File

@ -32,14 +32,14 @@ time_it(const int count, const int iterations, const unsigned char *salt,
saltlen, inlen); saltlen, inlen);
fflush(stdout); fflush(stdout);
isc_time_now_hires(&start); start = isc_time_now_hires();
int i = 0; int i = 0;
while (i++ < count) { while (i++ < count) {
isc_iterated_hash(out, 1, iterations, salt, saltlen, in, inlen); isc_iterated_hash(out, 1, iterations, salt, saltlen, in, inlen);
} }
isc_time_now_hires(&finish); finish = isc_time_now_hires();
uint64_t microseconds = isc_time_microdiff(&finish, &start); uint64_t microseconds = isc_time_microdiff(&finish, &start);
printf("%0.2f us per iterated_hash()\n", (double)microseconds / count); printf("%0.2f us per iterated_hash()\n", (double)microseconds / count);

View File

@ -278,7 +278,7 @@ main(int argc, char *argv[]) {
for (struct fun *fun = fun_list; fun->name != NULL; fun++) { for (struct fun *fun = fun_list; fun->name != NULL; fun++) {
isc_time_t t0; isc_time_t t0;
isc_time_now_hires(&t0); t0 = isc_time_now_hires();
isc_mem_t *mem = NULL; isc_mem_t *mem = NULL;
isc_mem_create(&mem); isc_mem_create(&mem);
@ -291,7 +291,7 @@ main(int argc, char *argv[]) {
fun->sqz(map); fun->sqz(map);
isc_time_t t1; isc_time_t t1;
isc_time_now_hires(&t1); t1 = isc_time_now_hires();
for (count = 0; count < lines; count++) { for (count = 0; count < lines; count++) {
void *pval = NULL; void *pval = NULL;
@ -301,7 +301,7 @@ main(int argc, char *argv[]) {
} }
isc_time_t t2; isc_time_t t2;
isc_time_now_hires(&t2); t2 = isc_time_now_hires();
printf("%f sec to load %s\n", printf("%f sec to load %s\n",
(double)isc_time_microdiff(&t1, &t0) / (1000.0 * 1000.0), (double)isc_time_microdiff(&t1, &t0) / (1000.0 * 1000.0),

View File

@ -39,7 +39,7 @@ main(void) {
uint64_t sum = 0; uint64_t sum = 0;
uint64_t us; uint64_t us;
isc_time_now_hires(&start); start = isc_time_now_hires();
for (size_t end = len; end < SIZE; end += len) { for (size_t end = len; end < SIZE; end += len) {
uint64_t hash; uint64_t hash;
@ -50,7 +50,7 @@ main(void) {
count++; count++;
} }
isc_time_now_hires(&finish); finish = isc_time_now_hires();
us = isc_time_microdiff(&finish, &start); us = isc_time_microdiff(&finish, &start);
printf("%f us wide-lower len %3zu, %7.0f kh/s (%llx)\n", printf("%f us wide-lower len %3zu, %7.0f kh/s (%llx)\n",
@ -64,7 +64,7 @@ main(void) {
uint64_t sum = 0; uint64_t sum = 0;
uint64_t us; uint64_t us;
isc_time_now_hires(&start); start = isc_time_now_hires();
for (size_t end = len; end < SIZE; end += len) { for (size_t end = len; end < SIZE; end += len) {
uint64_t hash; uint64_t hash;
@ -74,7 +74,7 @@ main(void) {
count++; count++;
} }
isc_time_now_hires(&finish); finish = isc_time_now_hires();
us = isc_time_microdiff(&finish, &start); us = isc_time_microdiff(&finish, &start);
printf("%f us wide-icase len %3zu, %7.0f kh/s (%llx)\n", printf("%f us wide-icase len %3zu, %7.0f kh/s (%llx)\n",
@ -87,7 +87,7 @@ main(void) {
uint64_t sum = 0; uint64_t sum = 0;
uint64_t us; uint64_t us;
isc_time_now_hires(&start); start = isc_time_now_hires();
for (size_t end = len; end < SIZE; end += len) { for (size_t end = len; end < SIZE; end += len) {
uint64_t hash; uint64_t hash;
@ -97,7 +97,7 @@ main(void) {
count++; count++;
} }
isc_time_now_hires(&finish); finish = isc_time_now_hires();
us = isc_time_microdiff(&finish, &start); us = isc_time_microdiff(&finish, &start);
printf("%f us wide-bytes len %3zu, %7.0f kh/s (%llx)\n", printf("%f us wide-bytes len %3zu, %7.0f kh/s (%llx)\n",
@ -111,7 +111,7 @@ main(void) {
uint64_t sum = 0; uint64_t sum = 0;
uint64_t us; uint64_t us;
isc_time_now_hires(&start); start = isc_time_now_hires();
for (size_t end = len; end < SIZE; end += len) { for (size_t end = len; end < SIZE; end += len) {
uint32_t hash; uint32_t hash;
@ -122,7 +122,7 @@ main(void) {
count++; count++;
} }
isc_time_now_hires(&finish); finish = isc_time_now_hires();
us = isc_time_microdiff(&finish, &start); us = isc_time_microdiff(&finish, &start);
printf("%f us half-lower len %3zu, %7.0f kh/s (%llx)\n", printf("%f us half-lower len %3zu, %7.0f kh/s (%llx)\n",
@ -136,7 +136,7 @@ main(void) {
uint64_t sum = 0; uint64_t sum = 0;
uint64_t us; uint64_t us;
isc_time_now_hires(&start); start = isc_time_now_hires();
for (size_t end = len; end < SIZE; end += len) { for (size_t end = len; end < SIZE; end += len) {
uint32_t hash; uint32_t hash;
@ -146,7 +146,7 @@ main(void) {
count++; count++;
} }
isc_time_now_hires(&finish); finish = isc_time_now_hires();
us = isc_time_microdiff(&finish, &start); us = isc_time_microdiff(&finish, &start);
printf("%f us half-icase len %3zu, %7.0f kh/s (%llx)\n", printf("%f us half-icase len %3zu, %7.0f kh/s (%llx)\n",
@ -160,7 +160,7 @@ main(void) {
uint64_t sum = 0; uint64_t sum = 0;
uint64_t us; uint64_t us;
isc_time_now_hires(&start); start = isc_time_now_hires();
for (size_t end = len; end < SIZE; end += len) { for (size_t end = len; end < SIZE; end += len) {
uint32_t hash; uint32_t hash;
@ -170,7 +170,7 @@ main(void) {
count++; count++;
} }
isc_time_now_hires(&finish); finish = isc_time_now_hires();
us = isc_time_microdiff(&finish, &start); us = isc_time_microdiff(&finish, &start);
printf("%f us half-bytes len %3zu, %7.0f kh/s (%llx)\n", printf("%f us half-bytes len %3zu, %7.0f kh/s (%llx)\n",

View File

@ -1246,8 +1246,7 @@ ISC_RUN_TEST_IMPL(benchmark) {
node->data = (void *)(intptr_t)i; node->data = (void *)(intptr_t)i;
} }
result = isc_time_now(&ts1); ts1 = isc_time_now();
assert_int_equal(result, ISC_R_SUCCESS);
nthreads = ISC_MIN(isc_os_ncpus(), 32); nthreads = ISC_MIN(isc_os_ncpus(), 32);
nthreads = ISC_MAX(nthreads, 1); nthreads = ISC_MAX(nthreads, 1);
@ -1259,8 +1258,7 @@ ISC_RUN_TEST_IMPL(benchmark) {
isc_thread_join(threads[i], NULL); isc_thread_join(threads[i], NULL);
} }
result = isc_time_now(&ts2); ts2 = isc_time_now();
assert_int_equal(result, ISC_R_SUCCESS);
t = isc_time_microdiff(&ts2, &ts1); t = isc_time_microdiff(&ts2, &ts1);

View File

@ -133,7 +133,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_unreachable) {
UNUSED(arg); UNUSED(arg);
TIME_NOW(&now); now = isc_time_now();
dns_zonemgr_create(mctx, loopmgr, netmgr, &myzonemgr); dns_zonemgr_create(mctx, loopmgr, netmgr, &myzonemgr);

View File

@ -516,12 +516,10 @@ ISC_RUN_TEST_IMPL(isc_mem_benchmark) {
isc_thread_t threads[32]; isc_thread_t threads[32];
isc_time_t ts1, ts2; isc_time_t ts1, ts2;
double t; double t;
isc_result_t result;
atomic_init(&mem_size, ITEM_SIZE); atomic_init(&mem_size, ITEM_SIZE);
result = isc_time_now(&ts1); ts1 = isc_time_now();
assert_int_equal(result, ISC_R_SUCCESS);
for (int i = 0; i < nthreads; i++) { for (int i = 0; i < nthreads; i++) {
isc_thread_create(mem_thread, mctx, &threads[i]); isc_thread_create(mem_thread, mctx, &threads[i]);
@ -530,8 +528,7 @@ ISC_RUN_TEST_IMPL(isc_mem_benchmark) {
isc_thread_join(threads[i], NULL); isc_thread_join(threads[i], NULL);
} }
result = isc_time_now(&ts2); ts2 = isc_time_now();
assert_int_equal(result, ISC_R_SUCCESS);
t = isc_time_microdiff(&ts2, &ts1); t = isc_time_microdiff(&ts2, &ts1);

View File

@ -81,7 +81,7 @@ tick(void *arg) {
ticks++; ticks++;
assert_int_equal(isc_time_now(&tick_time), ISC_R_SUCCESS); tick_time = isc_time_now();
isc_ratelimiter_shutdown(rl); isc_ratelimiter_shutdown(rl);
isc_ratelimiter_detach(&rl); isc_ratelimiter_detach(&rl);
@ -92,7 +92,7 @@ tick(void *arg) {
ISC_LOOP_SETUP_IMPL(ratelimiter_common) { ISC_LOOP_SETUP_IMPL(ratelimiter_common) {
assert_null(rl); assert_null(rl);
isc_time_set(&tick_time, 0, 0); isc_time_set(&tick_time, 0, 0);
assert_int_equal(isc_time_now(&start_time), ISC_R_SUCCESS); start_time = isc_time_now();
isc_ratelimiter_create(mainloop, &rl); isc_ratelimiter_create(mainloop, &rl);
} }
@ -191,7 +191,7 @@ tock(void *arg) {
isc_mem_put(mctx, rlstat, sizeof(*rlstat)); isc_mem_put(mctx, rlstat, sizeof(*rlstat));
ticks++; ticks++;
assert_int_equal(isc_time_now(&tock_time), ISC_R_SUCCESS); tock_time = isc_time_now();
} }
ISC_LOOP_SETUP_IMPL(ratelimiter_pertick_interval) { ISC_LOOP_SETUP_IMPL(ratelimiter_pertick_interval) {

View File

@ -143,8 +143,7 @@ ISC_RUN_TEST_IMPL(isc_time_parsehttptimestamp_test) {
UNUSED(state); UNUSED(state);
setenv("TZ", "America/Los_Angeles", 1); setenv("TZ", "America/Los_Angeles", 1);
result = isc_time_now(&t); t = isc_time_now();
assert_int_equal(result, ISC_R_SUCCESS);
isc_time_formathttptimestamp(&t, buf, sizeof(buf)); isc_time_formathttptimestamp(&t, buf, sizeof(buf));
result = isc_time_parsehttptimestamp(buf, &x); result = isc_time_parsehttptimestamp(buf, &x);
@ -155,15 +154,13 @@ ISC_RUN_TEST_IMPL(isc_time_parsehttptimestamp_test) {
/* print UTC in ISO8601 */ /* print UTC in ISO8601 */
ISC_RUN_TEST_IMPL(isc_time_formatISO8601_test) { ISC_RUN_TEST_IMPL(isc_time_formatISO8601_test) {
isc_result_t result;
isc_time_t t; isc_time_t t;
char buf[64]; char buf[64];
UNUSED(state); UNUSED(state);
setenv("TZ", "America/Los_Angeles", 1); setenv("TZ", "America/Los_Angeles", 1);
result = isc_time_now(&t); t = isc_time_now();
assert_int_equal(result, ISC_R_SUCCESS);
/* check formatting: yyyy-mm-ddThh:mm:ssZ */ /* check formatting: yyyy-mm-ddThh:mm:ssZ */
memset(buf, 'X', sizeof(buf)); memset(buf, 'X', sizeof(buf));
@ -191,15 +188,13 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601_test) {
/* print UTC in ISO8601 with milliseconds */ /* print UTC in ISO8601 with milliseconds */
ISC_RUN_TEST_IMPL(isc_time_formatISO8601ms_test) { ISC_RUN_TEST_IMPL(isc_time_formatISO8601ms_test) {
isc_result_t result;
isc_time_t t; isc_time_t t;
char buf[64]; char buf[64];
UNUSED(state); UNUSED(state);
setenv("TZ", "America/Los_Angeles", 1); setenv("TZ", "America/Los_Angeles", 1);
result = isc_time_now(&t); t = isc_time_now();
assert_int_equal(result, ISC_R_SUCCESS);
/* check formatting: yyyy-mm-ddThh:mm:ss.sssZ */ /* check formatting: yyyy-mm-ddThh:mm:ss.sssZ */
memset(buf, 'X', sizeof(buf)); memset(buf, 'X', sizeof(buf));
@ -228,15 +223,13 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601ms_test) {
/* print UTC in ISO8601 with microseconds */ /* print UTC in ISO8601 with microseconds */
ISC_RUN_TEST_IMPL(isc_time_formatISO8601us_test) { ISC_RUN_TEST_IMPL(isc_time_formatISO8601us_test) {
isc_result_t result;
isc_time_t t; isc_time_t t;
char buf[64]; char buf[64];
UNUSED(state); UNUSED(state);
setenv("TZ", "America/Los_Angeles", 1); setenv("TZ", "America/Los_Angeles", 1);
result = isc_time_now_hires(&t); t = isc_time_now_hires();
assert_int_equal(result, ISC_R_SUCCESS);
/* check formatting: yyyy-mm-ddThh:mm:ss.ssssssZ */ /* check formatting: yyyy-mm-ddThh:mm:ss.ssssssZ */
memset(buf, 'X', sizeof(buf)); memset(buf, 'X', sizeof(buf));
@ -265,15 +258,13 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601us_test) {
/* print local time in ISO8601 */ /* print local time in ISO8601 */
ISC_RUN_TEST_IMPL(isc_time_formatISO8601L_test) { ISC_RUN_TEST_IMPL(isc_time_formatISO8601L_test) {
isc_result_t result;
isc_time_t t; isc_time_t t;
char buf[64]; char buf[64];
UNUSED(state); UNUSED(state);
setenv("TZ", "America/Los_Angeles", 1); setenv("TZ", "America/Los_Angeles", 1);
result = isc_time_now(&t); t = isc_time_now();
assert_int_equal(result, ISC_R_SUCCESS);
/* check formatting: yyyy-mm-ddThh:mm:ss */ /* check formatting: yyyy-mm-ddThh:mm:ss */
memset(buf, 'X', sizeof(buf)); memset(buf, 'X', sizeof(buf));
@ -300,15 +291,13 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601L_test) {
/* print local time in ISO8601 with milliseconds */ /* print local time in ISO8601 with milliseconds */
ISC_RUN_TEST_IMPL(isc_time_formatISO8601Lms_test) { ISC_RUN_TEST_IMPL(isc_time_formatISO8601Lms_test) {
isc_result_t result;
isc_time_t t; isc_time_t t;
char buf[64]; char buf[64];
UNUSED(state); UNUSED(state);
setenv("TZ", "America/Los_Angeles", 1); setenv("TZ", "America/Los_Angeles", 1);
result = isc_time_now(&t); t = isc_time_now();
assert_int_equal(result, ISC_R_SUCCESS);
/* check formatting: yyyy-mm-ddThh:mm:ss.sss */ /* check formatting: yyyy-mm-ddThh:mm:ss.sss */
memset(buf, 'X', sizeof(buf)); memset(buf, 'X', sizeof(buf));
@ -336,15 +325,13 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601Lms_test) {
/* print local time in ISO8601 with microseconds */ /* print local time in ISO8601 with microseconds */
ISC_RUN_TEST_IMPL(isc_time_formatISO8601Lus_test) { ISC_RUN_TEST_IMPL(isc_time_formatISO8601Lus_test) {
isc_result_t result;
isc_time_t t; isc_time_t t;
char buf[64]; char buf[64];
UNUSED(state); UNUSED(state);
setenv("TZ", "America/Los_Angeles", 1); setenv("TZ", "America/Los_Angeles", 1);
result = isc_time_now_hires(&t); t = isc_time_now_hires();
assert_int_equal(result, ISC_R_SUCCESS);
/* check formatting: yyyy-mm-ddThh:mm:ss.ssssss */ /* check formatting: yyyy-mm-ddThh:mm:ss.ssssss */
memset(buf, 'X', sizeof(buf)); memset(buf, 'X', sizeof(buf));
@ -372,15 +359,13 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601Lus_test) {
/* print UTC time as yyyymmddhhmmsssss */ /* print UTC time as yyyymmddhhmmsssss */
ISC_RUN_TEST_IMPL(isc_time_formatshorttimestamp_test) { ISC_RUN_TEST_IMPL(isc_time_formatshorttimestamp_test) {
isc_result_t result;
isc_time_t t; isc_time_t t;
char buf[64]; char buf[64];
UNUSED(state); UNUSED(state);
setenv("TZ", "America/Los_Angeles", 1); setenv("TZ", "America/Los_Angeles", 1);
result = isc_time_now(&t); t = isc_time_now();
assert_int_equal(result, ISC_R_SUCCESS);
/* check formatting: yyyymmddhhmmsssss */ /* check formatting: yyyymmddhhmmsssss */
memset(buf, 'X', sizeof(buf)); memset(buf, 'X', sizeof(buf));

View File

@ -66,12 +66,10 @@ setup_test_run(void *data) {
isc_timertype_t timertype = ((setup_test_arg_t *)data)->timertype; isc_timertype_t timertype = ((setup_test_arg_t *)data)->timertype;
isc_interval_t *interval = ((setup_test_arg_t *)data)->interval; isc_interval_t *interval = ((setup_test_arg_t *)data)->interval;
isc_job_cb action = ((setup_test_arg_t *)data)->action; isc_job_cb action = ((setup_test_arg_t *)data)->action;
isc_result_t result;
isc_mutex_lock(&lasttime_mx); isc_mutex_lock(&lasttime_mx);
result = isc_time_now(&lasttime); lasttime = isc_time_now();
UNLOCK(&lasttime_mx); UNLOCK(&lasttime_mx);
assert_int_equal(result, ISC_R_SUCCESS);
isc_timer_create(mainloop, action, (void *)timertype, &timer); isc_timer_create(mainloop, action, (void *)timertype, &timer);
isc_timer_start(timer, timertype, interval); isc_timer_start(timer, timertype, interval);
@ -144,8 +142,7 @@ ticktock(void *arg) {
print_message("# tick %d\n", tick); print_message("# tick %d\n", tick);
} }
result = isc_time_now(&now); now = isc_time_now();
subthread_assert_result_equal(result, ISC_R_SUCCESS);
isc_interval_set(&interval, seconds, nanoseconds); isc_interval_set(&interval, seconds, nanoseconds);
isc_mutex_lock(&lasttime_mx); isc_mutex_lock(&lasttime_mx);
@ -170,8 +167,7 @@ ticktock(void *arg) {
subthread_assert_result_equal(result, ISC_R_SUCCESS); subthread_assert_result_equal(result, ISC_R_SUCCESS);
if (atomic_load(&eventcnt) == nevents) { if (atomic_load(&eventcnt) == nevents) {
result = isc_time_now(&endtime); endtime = isc_time_now();
subthread_assert_result_equal(result, ISC_R_SUCCESS);
isc_timer_destroy(&timer); isc_timer_destroy(&timer);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown(loopmgr);
} }
@ -212,8 +208,7 @@ test_idle(void *arg) {
print_message("# tick %d\n", tick); print_message("# tick %d\n", tick);
} }
result = isc_time_now(&now); now = isc_time_now();
subthread_assert_result_equal(result, ISC_R_SUCCESS);
isc_interval_set(&interval, seconds, nanoseconds); isc_interval_set(&interval, seconds, nanoseconds);
isc_mutex_lock(&lasttime_mx); isc_mutex_lock(&lasttime_mx);
@ -276,8 +271,7 @@ test_reset(void *arg) {
* Check expired time. * Check expired time.
*/ */
result = isc_time_now(&now); now = isc_time_now();
subthread_assert_result_equal(result, ISC_R_SUCCESS);
isc_interval_set(&interval, seconds, nanoseconds); isc_interval_set(&interval, seconds, nanoseconds);
isc_mutex_lock(&lasttime_mx); isc_mutex_lock(&lasttime_mx);

View File

@ -434,7 +434,7 @@ ns_test_qctx_create(const ns_test_qctx_create_params_t *params,
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
return (result); return (result);
} }
TIME_NOW(&client->tnow); client->tnow = isc_time_now();
/* /*
* Every client needs to belong to a view. * Every client needs to belong to a view.