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

amc pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  837d838   TS-4966: Fix process manager thread to support TS API.
837d838 is described below

commit 837d838b096f9ec6d1a663dac136f294c73cda66
Author: Alan M. Carroll <solidwallofc...@yahoo-inc.com>
AuthorDate: Thu Oct 13 11:08:57 2016 -0500

    TS-4966: Fix process manager thread to support TS API.
---
 mgmt/ProcessManager.cc |  3 +++
 mgmt/ProcessManager.h  | 12 +++++++++++-
 proxy/Main.cc          |  5 ++++-
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/mgmt/ProcessManager.cc b/mgmt/ProcessManager.cc
index 909a9c1..face2a9 100644
--- a/mgmt/ProcessManager.cc
+++ b/mgmt/ProcessManager.cc
@@ -54,6 +54,9 @@ startProcessManager(void *arg)
     pmgmt->initLMConnection();
   }
 
+  if (pmgmt->init)
+    pmgmt->init();
+
   for (;;) {
     if (unlikely(shutdown_event_system == true)) {
       return NULL;
diff --git a/mgmt/ProcessManager.h b/mgmt/ProcessManager.h
index e987906..7e728d4 100644
--- a/mgmt/ProcessManager.h
+++ b/mgmt/ProcessManager.h
@@ -41,6 +41,7 @@
 #include "ts/ink_sock.h"
 
 #include "ts/ink_apidefs.h"
+#include <functional>
 
 class ConfigUpdateCbTable;
 
@@ -59,9 +60,14 @@ public:
     ats_free(mgmt_signal_queue);
   }
 
+  /** Start a thread for the process manager.
+
+      If @a cb is set then it is called after the thread is started and before 
any messages are processed.
+  */
   void
-  start()
+  start(std::function<void()> const &cb = std::function<void()>())
   {
+    init = cb;
     ink_thread_create(startProcessManager, NULL, 0, 0, NULL);
   }
 
@@ -97,6 +103,10 @@ public:
 
   pid_t pid;
 
+  /// Thread initialization callback.
+  /// This allows @c traffic_server and @c traffic_manager to perform 
different initialization in the thread.
+  std::function<void()> init;
+
   int local_manager_sockfd;
 
 private:
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 125558d..7334c55 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -501,7 +501,10 @@ initialize_process_manager()
   // Start up manager
   pmgmt = new ProcessManager(remote_management_flag);
 
-  pmgmt->start();
+  // Lifecycle callbacks can potentially be invoked from this thread, so force 
thread initialization
+  // to make the TS API work. Use a lambda to avoid dealing with compiler 
dependent casting issues.
+  pmgmt->start([]() -> void { TSThreadInit(); });
+
   RecProcessInitMessage(remote_management_flag ? RECM_CLIENT : 
RECM_STAND_ALONE);
   pmgmt->reconfigure();
   check_config_directories();

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Reply via email to