You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2018/04/24 22:46:09 UTC

[trafficserver] branch master updated: Clean up state machine id and make it 64 bit

This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 026c1fb  Clean up state machine id and make it 64 bit
026c1fb is described below

commit 026c1fbe432f8a68566dff3a7ded8c75864f2703
Author: Bryan Call <bc...@apache.org>
AuthorDate: Tue Apr 24 10:39:35 2018 -0700

    Clean up state machine id and make it 64 bit
---
 proxy/http/HttpSM.cc | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 90cd2c5..cede6eb 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -46,6 +46,7 @@
 #include <openssl/ossl_typ.h>
 #include <openssl/ssl.h>
 #include <algorithm>
+#include <atomic>
 
 #define DEFAULT_RESPONSE_BUFFER_SIZE_INDEX 6 // 8K
 #define DEFAULT_REQUEST_BUFFER_SIZE_INDEX 6  // 8K
@@ -116,6 +117,9 @@ milestone_update_api_time(TransactionMilestones &milestones, ink_hrtime &api_tim
     }
   }
 }
+
+// Unique state machine identifier
+std::atomic<int64_t> next_sm_id(0);
 }
 
 ClassAllocator<HttpSM> httpSMAllocator("httpSMAllocator");
@@ -250,8 +254,6 @@ HttpVCTable::cleanup_all()
     default_handler = _h;                 \
   }
 
-static int next_sm_id = 0;
-
 HttpSM::HttpSM() : Continuation(nullptr)
 {
   ink_zero(vc_table);
@@ -295,17 +297,9 @@ HttpSM::init()
   milestones[TS_MILESTONE_SM_START] = Thread::get_hrtime();
 
   magic = HTTP_SM_MAGIC_ALIVE;
-  sm_id = 0;
-
-  // Unique state machine identifier.
-  //  changed next_sm_id from int64_t to int because
-  //  atomic(32) is faster than atomic64.  The id is just
-  //  for debugging, so it's OK if it wraps every few days,
-  //  as long as the http_info bucket hash still works.
-  //  (To test this, initialize next_sm_id to 0x7ffffff0)
-  //  Leaving sm_id as int64_t to minimize code changes.
 
-  sm_id                    = (int64_t)ink_atomic_increment((&next_sm_id), 1);
+  // Unique state machine identifier
+  sm_id                    = next_sm_id++;
   t_state.state_machine_id = sm_id;
   t_state.state_machine    = this;
 

-- 
To stop receiving notification emails like this one, please contact
bcall@apache.org.