From 9978ceb26327de9545c6e0a4f9230b401e629793 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Mon, 10 Aug 2020 11:45:58 +0300 Subject: libglusterfs: add library wrapper for time() Add thin convenient library wrapper gf_time(), adjust related users and comments as well. Change-Id: If8969af2f45ee69c30c3406bce5baa8305fb7f80 Signed-off-by: Dmitry Antipov Updates: #1002 --- libglusterfs/src/common-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libglusterfs/src/common-utils.c') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index c37c45449f2..bff4c3d633b 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -646,7 +646,7 @@ gf_rev_dns_lookup_cached(const char *ip, struct dnscache *dnscache) if (entrydata) { dnsentry = (struct dnscache_entry *)entrydata->data; /* First check the TTL & timestamp */ - if (time(NULL) - dnsentry->timestamp > dnscache->ttl) { + if (gf_time() - dnsentry->timestamp > dnscache->ttl) { gf_dnscache_entry_deinit(dnsentry); entrydata->data = NULL; /* Mark this as 'null' so * dict_del () doesn't try free @@ -683,7 +683,7 @@ out: if (entry) { entry->fqdn = fqdn; entry->ip = gf_strdup(ip); - entry->timestamp = time(NULL); + entry->timestamp = gf_time(); entrydata = bin_to_data(entry, sizeof(*entry)); dict_set(cache, (char *)ip, entrydata); } @@ -935,7 +935,7 @@ gf_print_trace(int32_t signum, glusterfs_ctx_t *ctx) { /* Dump the timestamp of the crash too, so the previous logs can be related */ - gf_time_fmt(timestr, sizeof timestr, time(NULL), gf_timefmt_FT); + gf_time_fmt(timestr, sizeof timestr, gf_time(), gf_timefmt_FT); gf_msg_plain_nomem(GF_LOG_ALERT, "time of crash: "); gf_msg_plain_nomem(GF_LOG_ALERT, timestr); } -- cgit