Repository: trafficserver Updated Branches: refs/heads/5.0.x 5e19587e3 -> 721d5cf50
TS-2622: optimize the function ink_cluster_time 1. remove useless two global variables 2. use ink_get_hrtime() instead of time(NULL) 3. remove useless CAS to set variable global_time Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/8aa3af93 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/8aa3af93 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/8aa3af93 Branch: refs/heads/5.0.x Commit: 8aa3af937548942e8130ccdf1400e043870e3a0e Parents: a8ed22d Author: Yu Qing <[email protected]> Authored: Fri Mar 7 15:21:20 2014 +0800 Committer: James Peach <[email protected]> Committed: Wed Apr 9 16:25:13 2014 -0700 ---------------------------------------------------------------------- CHANGES | 3 +++ proxy/http/HttpTransact.cc | 22 ++++------------------ 2 files changed, 7 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8aa3af93/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 9f9e7aa..010a6e4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 5.0.0 + *) [TS-2622] Optimize the ink_cluster_time() function. + Author: Yu Qing <[email protected]> + *) [TS-2701] Silence traffic_cop logging on chown of missing lock files. *) [TS-2656 Determine server connection scheme immediately before http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8aa3af93/proxy/http/HttpTransact.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index 0f464e6..c5ee223 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -8333,23 +8333,18 @@ HttpTransact::get_error_string(int erno) } } - -volatile ink_time_t global_time; -volatile int32_t cluster_time_delta; - ink_time_t ink_cluster_time(void) { - ink_time_t old; - int highest_delta = 0; + int highest_delta; #ifdef DEBUG ink_mutex_acquire(&http_time_lock); - ink_time_t local_time = time(NULL); + ink_time_t local_time = ink_get_hrtime() / HRTIME_SECOND; last_http_local_time = local_time; ink_mutex_release(&http_time_lock); #else - ink_time_t local_time = time(NULL); + ink_time_t local_time = ink_get_hrtime() / HRTIME_SECOND; #endif highest_delta = (int) HttpConfig::m_master.cluster_time_delta; @@ -8366,16 +8361,7 @@ ink_cluster_time(void) ink_assert(highest_delta >= 0); - local_time += (ink_time_t) highest_delta; - old = global_time; - - while (local_time > global_time) { - if (ink_atomic_cas(&global_time, old, local_time)) - break; - old = global_time; - } - - return global_time; + return local_time + (ink_time_t) highest_delta; } //
