trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yun...@apache.org
Subject [3/3] git commit: TS-2141: Make traffic_cop reconnect to manager correctly
Date Wed, 21 Aug 2013 09:43:30 GMT
TS-2141: Make traffic_cop reconnect to manager correctly

1) By removing "TS_MGMT_OPT_NO_SOCK_TESTS" option when calls
   TSInit() in traffic_cop, cop will reconnect to manager correctly
   again.

2) Fix some small bugs about usage of pthread.

Signed-off-by: Yunkai Zhang <qiushu.zyk@taobao.com>


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/5f4b470c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/5f4b470c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/5f4b470c

Branch: refs/heads/master
Commit: 5f4b470cedcd4bd6d0b1f54c55b15662a0fe8ce8
Parents: ce9188b
Author: Yunkai Zhang <qiushu.zyk@taobao.com>
Authored: Tue Aug 20 22:11:10 2013 +0800
Committer: Yunkai Zhang <qiushu.zyk@taobao.com>
Committed: Wed Aug 21 17:42:48 2013 +0800

----------------------------------------------------------------------
 cop/TrafficCop.cc                     | 2 +-
 mgmt/api/remote/CoreAPIRemote.cc      | 9 +++++++++
 mgmt/api/remote/EventRegistration.cc  | 1 +
 mgmt/api/remote/NetworkUtilsRemote.cc | 2 +-
 4 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5f4b470c/cop/TrafficCop.cc
----------------------------------------------------------------------
diff --git a/cop/TrafficCop.cc b/cop/TrafficCop.cc
index 0b03c31..a681704 100644
--- a/cop/TrafficCop.cc
+++ b/cop/TrafficCop.cc
@@ -1593,7 +1593,7 @@ check(void *arg)
 
     // We do this after the first round of checks, since the first "check" will spawn traffic_manager
     if (!mgmt_init) {
-      TSInit(Layout::get()->runtimedir, static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS
| TS_MGMT_OPT_NO_SOCK_TESTS));
+      TSInit(Layout::get()->runtimedir, static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS));
       mgmt_init = true;
     }
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5f4b470c/mgmt/api/remote/CoreAPIRemote.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/remote/CoreAPIRemote.cc b/mgmt/api/remote/CoreAPIRemote.cc
index 878ed11..cb2ae5c 100644
--- a/mgmt/api/remote/CoreAPIRemote.cc
+++ b/mgmt/api/remote/CoreAPIRemote.cc
@@ -311,6 +311,15 @@ Terminate()
   if (ts_event_thread)
     ink_thread_cancel(ts_event_thread);
 
+  // Before clear, we should confirm these
+  // two threads have finished. Or the clear
+  // operation may lead them crash.
+  if (ts_test_thread)
+    ink_thread_join(ts_test_thread);
+  if (ts_event_thread)
+    ink_thread_join(ts_event_thread);
+
+  // Clear operation
   ts_test_thread = static_cast<ink_thread>(NULL);
   ts_event_thread = static_cast<ink_thread>(NULL);
   set_socket_paths(NULL);       // clear the socket_path

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5f4b470c/mgmt/api/remote/EventRegistration.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/remote/EventRegistration.cc b/mgmt/api/remote/EventRegistration.cc
index 383a3da..2a3d7fb 100644
--- a/mgmt/api/remote/EventRegistration.cc
+++ b/mgmt/api/remote/EventRegistration.cc
@@ -161,5 +161,6 @@ event_callback_thread(void *arg)
   delete_queue(func_q);
 
   // all done!
+  ink_thread_exit(NULL);
   return NULL;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5f4b470c/mgmt/api/remote/NetworkUtilsRemote.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/remote/NetworkUtilsRemote.cc b/mgmt/api/remote/NetworkUtilsRemote.cc
index bcf794a..92a2e55 100644
--- a/mgmt/api/remote/NetworkUtilsRemote.cc
+++ b/mgmt/api/remote/NetworkUtilsRemote.cc
@@ -459,7 +459,7 @@ socket_test_thread(void *)
 {
   // loop until client process dies
   while (1) {
-    if (socket_test(main_socket_fd) <= 0) {
+    if (main_socket_fd == -1 || socket_test(main_socket_fd) <= 0) {
       // ASSUMES that in between the time the socket_test is made
       // and this reconnect call is made, the main_socket_fd remains
       // the same (eg. no one else called reconnect to TM successfully!!


Mime
View raw message