Repository: trafficserver Updated Branches: refs/heads/master 41ca9dfbf -> 48d7b25ba
Minor cleanup to always use ink_gettimeofday. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/48d7b25b Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/48d7b25b Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/48d7b25b Branch: refs/heads/master Commit: 48d7b25ba8a8229b0471d37cdaa6ef24cc634bb0 Parents: 41ca9df Author: James Peach <[email protected]> Authored: Tue Apr 5 22:43:27 2016 -0700 Committer: James Peach <[email protected]> Committed: Fri Apr 8 20:44:29 2016 -0700 ---------------------------------------------------------------------- cmd/traffic_cop/traffic_cop.cc | 8 ++++---- lib/ts/Diags.cc | 2 +- lib/ts/ink_hrtime.h | 16 ---------------- proxy/logging/Log.cc | 5 ++--- proxy/logging/LogBuffer.cc | 3 +-- 5 files changed, 8 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48d7b25b/cmd/traffic_cop/traffic_cop.cc ---------------------------------------------------------------------- diff --git a/cmd/traffic_cop/traffic_cop.cc b/cmd/traffic_cop/traffic_cop.cc index 8758514..034eb5c 100644 --- a/cmd/traffic_cop/traffic_cop.cc +++ b/cmd/traffic_cop/traffic_cop.cc @@ -186,7 +186,7 @@ cop_log(int priority, const char *format, ...) struct timeval now; double now_f; - gettimeofday(&now, NULL); + now = ink_gettimeofday(); now_f = now.tv_sec + now.tv_usec / 1000000.0f; fprintf(stdout, "<%.4f> [%s]: ", now_f, priority_name(priority)); @@ -418,14 +418,14 @@ safe_kill(const char *lockfile_name, const char *pname, bool group) static ink_hrtime milliseconds(void) { - struct timeval curTime; + struct timeval now; cop_log_trace("Entering milliseconds()\n"); - ink_gethrtimeofday(&curTime, NULL); + now = ink_gettimeofday(); // Make liberal use of casting to ink_hrtime to ensure the // compiler does not truncate our result cop_log_trace("Leaving milliseconds()\n"); - return ((ink_hrtime)curTime.tv_sec * 1000) + ((ink_hrtime)curTime.tv_usec / 1000); + return ((ink_hrtime)now.tv_sec * 1000) + ((ink_hrtime)now.tv_usec / 1000); } static void http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48d7b25b/lib/ts/Diags.cc ---------------------------------------------------------------------- diff --git a/lib/ts/Diags.cc b/lib/ts/Diags.cc index 28d6b91..36e607a 100644 --- a/lib/ts/Diags.cc +++ b/lib/ts/Diags.cc @@ -308,7 +308,7 @@ Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SrcLoc *loc // prepend timestamp into the timestamped version of the buffer // ////////////////////////////////////////////////////////////////// - ink_gethrtimeofday(&tp, NULL); + tp = ink_gettimeofday(); time_t cur_clock = (time_t)tp.tv_sec; buffer = ink_ctime_r(&cur_clock, timestamp_buf); snprintf(&(timestamp_buf[19]), (sizeof(timestamp_buf) - 20), ".%03d", (int)(tp.tv_usec / 1000)); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48d7b25b/lib/ts/ink_hrtime.h ---------------------------------------------------------------------- diff --git a/lib/ts/ink_hrtime.h b/lib/ts/ink_hrtime.h index 9e76deb..6e2ec5e 100644 --- a/lib/ts/ink_hrtime.h +++ b/lib/ts/ink_hrtime.h @@ -205,16 +205,6 @@ ink_hrtime_to_timeval(ink_hrtime t) return (tv); } -static inline int -ink_hrtime_to_timeval2(ink_hrtime t, struct timeval *tv) -{ - int64_t usecs = ink_hrtime_to_usec(t); - tv->tv_sec = usecs / 1000000; - tv->tv_usec = usecs % 1000000; - return 0; -} - - /* using Jan 1 1970 as the base year, instead of Jan 1 1601, which translates to (365 + 0.25)369*24*60*60 seconds */ @@ -242,12 +232,6 @@ ink_gettimeofday() } static inline int -ink_gethrtimeofday(struct timeval *tp, void *) -{ - return ink_hrtime_to_timeval2(ink_get_hrtime_internal(), tp); -} - -static inline int ink_time() { return (int)ink_hrtime_to_sec(ink_get_hrtime_internal()); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48d7b25b/proxy/logging/Log.cc ---------------------------------------------------------------------- diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc index aa5468a..0aa98b5 100644 --- a/proxy/logging/Log.cc +++ b/proxy/logging/Log.cc @@ -1125,10 +1125,9 @@ Log::trace_va(bool in, const sockaddr *peer_addr, uint16_t peer_port, const char char ip[INET6_ADDRSTRLEN]; ats_ip_ntop(peer_addr, ip, sizeof(ip)); - struct timeval tp; - ink_gethrtimeofday(&tp, NULL); + struct timeval tp = ink_gettimeofday(); - Log::error("[%9d.%03d] Trace {0x%" PRIx64 "} %s %s:%d: ", (int)tp.tv_sec, (int)(tp.tv_usec / 1000), (uint64_t)pthread_self(), + Log::error("[%9d.%03d] Trace {0x%" PRIx64 "} %s %s:%d: ", (int)tp.tv_sec, (int)(tp.tv_usec / 1000), (uint64_t)ink_thread_self(), in ? "RECV" : "SEND", ip, peer_port); Log::va_error(format_string, ap); Log::error("[End Trace]\n"); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48d7b25b/proxy/logging/LogBuffer.cc ---------------------------------------------------------------------- diff --git a/proxy/logging/LogBuffer.cc b/proxy/logging/LogBuffer.cc index a538de1..5ba2d62 100644 --- a/proxy/logging/LogBuffer.cc +++ b/proxy/logging/LogBuffer.cc @@ -288,9 +288,8 @@ LogBuffer::checkout_write(size_t *write_offset, size_t write_size) LogEntryHeader *entry_header = (LogEntryHeader *)&m_buffer[offset]; // entry_header->timestamp = LogUtils::timestamp(); - struct timeval tp; + struct timeval tp = ink_gettimeofday(); - ink_gethrtimeofday(&tp, 0); entry_header->timestamp = tp.tv_sec; entry_header->timestamp_usec = tp.tv_usec; entry_header->entry_len = actual_write_size;
