trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject [trafficserver] 05/08: ssl_session_reuse optimization to check if diags is on
Date Tue, 10 Dec 2019 23:21:34 GMT
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit a269ec302e2d28c08497e2bb93a3e52fcf26580a
Author: Bryan Call <bcall@apache.org>
AuthorDate: Tue Nov 19 10:40:53 2019 +0800

    ssl_session_reuse optimization to check if diags is on
    
    (cherry picked from commit 3a4fe4e02e61058002de34f70155a70e9927fae6)
---
 .../experimental/ssl_session_reuse/src/publish.cc  | 57 ++++++++++++++--------
 1 file changed, 37 insertions(+), 20 deletions(-)

diff --git a/plugins/experimental/ssl_session_reuse/src/publish.cc b/plugins/experimental/ssl_session_reuse/src/publish.cc
index 98bab37..9e2eb7e 100644
--- a/plugins/experimental/ssl_session_reuse/src/publish.cc
+++ b/plugins/experimental/ssl_session_reuse/src/publish.cc
@@ -35,11 +35,12 @@
 #include "Config.h"
 #include "redis_auth.h"
 #include "ssl_utils.h"
+#include <inttypes.h>
 
 void *
 RedisPublisher::start_worker_thread(void *arg)
 {
-  plugin_threads.store(::pthread_self());
+  plugin_threads.store(pthread_self());
   ::pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, nullptr);
   ::pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, nullptr);
 
@@ -117,8 +118,11 @@ RedisPublisher::is_good()
 ::redisContext *
 RedisPublisher::setup_connection(const RedisEndpoint &re)
 {
-  auto my_id = (unsigned long long)::pthread_self();
-  TSDebug(PLUGIN, "RedisPublisher::setup_connection: Called by threadId: %llx", my_id);
+  uint64_t my_id = 0;
+  if (TSIsDebugTagSet(PLUGIN)) {
+    my_id = (uint64_t)pthread_self();
+    TSDebug(PLUGIN, "RedisPublisher::setup_connection: Called by threadId: %" PRIx64, my_id);
+  }
 
   RedisContextPtr my_context;
   struct ::timeval timeout;
@@ -128,14 +132,15 @@ RedisPublisher::setup_connection(const RedisEndpoint &re)
   for (int i = 0; i < static_cast<int>(m_redisConnectTries); ++i) {
     my_context.reset(::redisConnectWithTimeout(re.m_hostname.c_str(), re.m_port, timeout));
     if (!my_context) {
-      TSError("RedisPublisher::setup_connection: Connect to host: %s port: %d fail count:
%d threadId: %llx", re.m_hostname.c_str(),
-              re.m_port, i + 1, my_id);
+      TSError("RedisPublisher::setup_connection: Connect to host: %s port: %d fail count:
%d threadId: %" PRIx64,
+              re.m_hostname.c_str(), re.m_port, i + 1, my_id);
     } else if (my_context->err) {
-      TSError("RedisPublisher::setup_connection: Connect to host: %s port: %d fail count:
%d threadId: %llx", re.m_hostname.c_str(),
-              re.m_port, i + 1, my_id);
+      TSError("RedisPublisher::setup_connection: Connect to host: %s port: %d fail count:
%d threadId: %" PRIx64,
+              re.m_hostname.c_str(), re.m_port, i + 1, my_id);
       my_context.reset(nullptr);
     } else {
-      TSDebug(PLUGIN, "RedisPublisher::setup_connection: threadId: %llx Successfully connected
to the redis instance.", my_id);
+      TSDebug(PLUGIN, "RedisPublisher::setup_connection: threadId: %" PRIx64 " Successfully
connected to the redis instance.",
+              my_id);
 
       redisReply *reply = static_cast<redisReply *>(redisCommand(my_context.get(),
"AUTH %s", redis_passwd.c_str()));
 
@@ -163,8 +168,11 @@ RedisPublisher::setup_connection(const RedisEndpoint &re)
 ::redisReply *
 RedisPublisher::send_publish(RedisContextPtr &ctx, const RedisEndpoint &re, const
Message &msg)
 {
-  auto my_id = (unsigned long long)::pthread_self();
-  TSDebug(PLUGIN, "RedisPublisher::send_publish: Called by threadId: %llx", my_id);
+  uint64_t my_id = 0;
+  if (TSIsDebugTagSet(PLUGIN)) {
+    my_id = (uint64_t)pthread_self();
+    TSDebug(PLUGIN, "RedisPublisher::send_publish: Called by threadId: %" PRIx64, my_id);
+  }
 
   ::redisReply *current_reply(nullptr);
 
@@ -173,7 +181,8 @@ RedisPublisher::send_publish(RedisContextPtr &ctx, const RedisEndpoint
&re, cons
       ctx.reset(setup_connection(re));
 
       if (!ctx) {
-        TSError("RedisPublisher::send_publish: Unable to setup a connection to the redis
server: %s:%d threadId: %llx try: %d",
+        TSError("RedisPublisher::send_publish: Unable to setup a connection to the redis
server: %s:%d threadId: %" PRIx64
+                " try: %d",
                 re.m_hostname.c_str(), re.m_port, my_id, (i + 1));
         continue;
       }
@@ -181,12 +190,12 @@ RedisPublisher::send_publish(RedisContextPtr &ctx, const RedisEndpoint
&re, cons
 
     current_reply = static_cast<redisReply *>(::redisCommand(ctx.get(), "PUBLISH %s
%s", msg.channel.c_str(), msg.data.c_str()));
     if (!current_reply) {
-      TSError("RedisPublisher::send_publish: Unable to get a reply from the server for publish.
threadId: %llx try: %d", my_id,
-              (i + 1));
+      TSError("RedisPublisher::send_publish: Unable to get a reply from the server for publish.
threadId: %" PRIx64 " try: %d",
+              my_id, (i + 1));
       ctx.reset(nullptr); // Clean up previous attempt
 
     } else if (REDIS_REPLY_ERROR == current_reply->type) {
-      TSError("RedisPublisher::send_publish: Server responded with error for publish. threadId:
%llx try: %d", my_id, i + 1);
+      TSError("RedisPublisher::send_publish: Server responded with error for publish. threadId:
%" PRIx64 " try: %d", my_id, i + 1);
       clear_reply(current_reply);
       current_reply = nullptr;
       ctx.reset(nullptr); // Clean up previous attempt
@@ -219,7 +228,6 @@ RedisPublisher::runWorker()
   }
   m_endpointIndexMutex.unlock();
 
-  auto my_id = (unsigned long long)::pthread_self();
   RedisContextPtr my_context;
   ::redisReply *current_reply(nullptr);
 
@@ -249,7 +257,10 @@ RedisPublisher::runWorker()
     ::sem_wait(&m_workerSem);
 
     if (current_message.cleanup) {
-      TSDebug(PLUGIN, "RedisPublisher::runWorker: threadId: %llx received the cleanup message.
Exiting!", my_id);
+      if (TSIsDebugTagSet(PLUGIN)) {
+        auto my_id = (uint64_t)pthread_self();
+        TSDebug(PLUGIN, "RedisPublisher::runWorker: threadId: %" PRIx64 " received the cleanup
message. Exiting!", my_id);
+      }
       break;
     }
     current_reply = send_publish(my_context, my_endpoint, current_message);
@@ -322,8 +333,11 @@ RedisPublisher::~RedisPublisher()
 std::string
 RedisPublisher::get_session(const std::string &channel)
 {
-  auto my_id = (unsigned long long)::pthread_self();
-  TSDebug(PLUGIN, "RedisPublisher::get_session: Called by threadId: %llx", my_id);
+  if (TSIsDebugTagSet(PLUGIN)) {
+    auto my_id = (uint64_t)pthread_self();
+    TSDebug(PLUGIN, "RedisPublisher::get_session: Called by threadId: %" PRIx64, my_id);
+  }
+
   std::string ret;
   uint32_t index    = get_hash_index(channel);
   redisReply *reply = nullptr;
@@ -355,8 +369,11 @@ RedisPublisher::get_session(const std::string &channel)
 redisReply *
 RedisPublisher::set_session(const Message &msg)
 {
-  auto my_id = (unsigned long long)::pthread_self();
-  TSDebug(PLUGIN, "RedisPublisher::set_session: Called by threadId: %llx", my_id);
+  if (TSIsDebugTagSet(PLUGIN)) {
+    auto my_id = (uint64_t)pthread_self();
+    TSDebug(PLUGIN, "RedisPublisher::set_session: Called by threadId: %" PRIx64, my_id);
+  }
+
   uint32_t index    = get_hash_index(msg.channel);
   redisReply *reply = nullptr;
   for (uint32_t i = 0; i < m_redisEndpoints.size(); i++) {


Mime
View raw message