You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/06/12 04:33:04 UTC

[2/3] trafficserver git commit: TS-3569 Replace UNSAFE_FORCE_MUTEX with an sdk_assert, and relax mutex requirements on Schedule()

TS-3569 Replace UNSAFE_FORCE_MUTEX with an sdk_assert, and relax mutex requirements on Schedule()


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

Branch: refs/heads/master
Commit: a36c416786c79c643cd11fd332274365bc893bb6
Parents: 5eaea51
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu May 7 14:21:08 2015 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Jun 11 20:31:04 2015 -0600

----------------------------------------------------------------------
 proxy/InkAPI.cc                    |  8 -------
 proxy/api/ts/InkAPIPrivateIOCore.h | 39 +++------------------------------
 2 files changed, 3 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a36c4167/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 53351e4..85343c4 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -1344,10 +1344,6 @@ api_init()
   if (init) {
     init = 0;
 
-#ifndef UNSAFE_FORCE_MUTEX
-    ink_mutex_init(&big_mux, "APIMongoMutex");
-#endif
-
     /* URL schemes */
     TS_URL_SCHEME_FILE = URL_SCHEME_FILE;
     TS_URL_SCHEME_FTP = URL_SCHEME_FTP;
@@ -4246,8 +4242,6 @@ TSContSchedule(TSCont contp, ink_hrtime timeout, TSThreadPool tp)
 {
   sdk_assert(sdk_sanity_check_iocore_structure(contp) == TS_SUCCESS);
 
-  FORCE_PLUGIN_MUTEX(contp);
-
   INKContInternal *i = (INKContInternal *)contp;
   TSAction action;
 
@@ -4300,8 +4294,6 @@ TSContScheduleEvery(TSCont contp, ink_hrtime every, TSThreadPool tp)
 {
   sdk_assert(sdk_sanity_check_iocore_structure(contp) == TS_SUCCESS);
 
-  FORCE_PLUGIN_MUTEX(contp);
-
   INKContInternal *i = (INKContInternal *)contp;
   TSAction action;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a36c4167/proxy/api/ts/InkAPIPrivateIOCore.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/InkAPIPrivateIOCore.h b/proxy/api/ts/InkAPIPrivateIOCore.h
index b4e8bff..9b7371a 100644
--- a/proxy/api/ts/InkAPIPrivateIOCore.h
+++ b/proxy/api/ts/InkAPIPrivateIOCore.h
@@ -107,42 +107,9 @@ public:
  *   We now take out the mutex on each call to ensure it is
  *   held for the entire duration of the IOCore call
  ***************************************************************/
-
-//
-// FORCE_PLUGIN_MUTEX -- define 'UNSAFE_FORCE_MUTEX' if you
-// do *not* want the locking macro to be thread safe.
-// Otherwise, access during 'null-mutex' case will be serialized
-// in a locking manner (too bad for the net threads).
-//
-
-
-#define UNSAFE_FORCE_MUTEX
-
-#ifdef UNSAFE_FORCE_MUTEX
-#define LOCK_MONGO_MUTEX
-#define UNLOCK_MONGO_MUTEX
-#define MUX_WARNING(p)                                                            \
-  TSDebug("sdk", "(SDK) null mutex detected in critical region (mutex created)"); \
-  TSDebug("sdk", "(SDK) please create continuation [%p] with mutex", (p));
-#else
-static ink_mutex big_mux;
-
-#define MUX_WARNING(p) 1
-#define LOCK_MONGO_MUTEX ink_mutex_acquire(&big_mux)
-#define UNLOCK_MONGO_MUTEX ink_mutex_release(&big_mux)
-#endif
-
-#define FORCE_PLUGIN_MUTEX(_c)                         \
-  bool do_warn = false;                                \
-  LOCK_MONGO_MUTEX;                                    \
-  if (((INKContInternal *)_c)->mutex == NULL) {        \
-    ((INKContInternal *)_c)->mutex = new_ProxyMutex(); \
-    do_warn = true;                                    \
-  }                                                    \
-  UNLOCK_MONGO_MUTEX;                                  \
-  if (do_warn)                                         \
-    MUX_WARNING(_c);                                   \
-  MUTEX_LOCK(ml, ((INKContInternal *)_c)->mutex, this_ethread());
+#define FORCE_PLUGIN_SCOPED_MUTEX(_c)         \
+  sdk_assert(((INKContInternal *)_c)->mutex); \
+  SCOPED_MUTEX_LOCK(ml, ((INKContInternal *)_c)->mutex, this_ethread());
 
 #ifdef __cplusplus
 extern "C" {