Repository: trafficserver Updated Branches: refs/heads/master 083abd4ff -> b4343175e
TS-2976: Fix overloaded global initialization flags. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b4343175 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b4343175 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b4343175 Branch: refs/heads/master Commit: b4343175e01dcce836aeca08d5354a7c80b9eab6 Parents: 083abd4 Author: Alan M. Carroll <[email protected]> Authored: Mon Aug 4 20:11:41 2014 -0500 Committer: Alan M. Carroll <[email protected]> Committed: Mon Aug 4 20:11:41 2014 -0500 ---------------------------------------------------------------------- lib/records/P_RecMessage.h | 2 +- lib/records/RecLocal.cc | 40 +++++++++++++++++++++++----------------- lib/records/RecMessage.cc | 24 ------------------------ lib/records/RecProcess.cc | 37 ++++++++++++++++++++----------------- 4 files changed, 44 insertions(+), 59 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4343175/lib/records/P_RecMessage.h ---------------------------------------------------------------------- diff --git a/lib/records/P_RecMessage.h b/lib/records/P_RecMessage.h index 1e68cb5..468ff03 100644 --- a/lib/records/P_RecMessage.h +++ b/lib/records/P_RecMessage.h @@ -30,7 +30,7 @@ // Initialization //------------------------------------------------------------------------- -int RecMessageInit(); +//int RecMessageInit(); void RecMessageRegister(); //------------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4343175/lib/records/RecLocal.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecLocal.cc b/lib/records/RecLocal.cc index f3ab11a..aca8eec 100644 --- a/lib/records/RecLocal.cc +++ b/lib/records/RecLocal.cc @@ -32,8 +32,8 @@ #include "LocalManager.h" #include "FileManager.h" -static bool g_initialized = false; -static bool g_message_initialized = false; +// Marks whether the message handler has been initialized. +static bool message_initialized_p = false; //------------------------------------------------------------------------- // i_am_the_record_owner, only used for libreclocal.a @@ -115,12 +115,25 @@ config_update_thr(void * /* data */) //------------------------------------------------------------------------- +// RecMessageInit +//------------------------------------------------------------------------- +void +RecMessageInit() +{ + ink_assert(g_mode_type != RECM_NULL); + lmgmt->registerMgmtCallback(MGMT_SIGNAL_LIBRECORDS, RecMessageRecvThis, NULL); + message_initialized_p = true; +} + +//------------------------------------------------------------------------- // RecLocalInit //------------------------------------------------------------------------- int RecLocalInit(Diags * _diags) { - if (g_initialized) { + static bool initialized_p = false;; + + if (initialized_p) { return REC_ERR_OKAY; } @@ -139,7 +152,7 @@ RecLocalInit(Diags * _diags) return REC_ERR_FAIL; } */ - g_initialized = true; + initialized_p = true; return REC_ERR_OKAY; } @@ -151,19 +164,18 @@ RecLocalInit(Diags * _diags) int RecLocalInitMessage() { - if (g_message_initialized) { - return REC_ERR_OKAY; - } + static bool initialized_p = false; - if (RecMessageInit() == REC_ERR_FAIL) { - return REC_ERR_FAIL; + if (initialized_p) { + return REC_ERR_OKAY; } + RecMessageInit(); if (RecMessageRegisterRecvCb(recv_message_cb, NULL)) { return REC_ERR_FAIL; } - g_message_initialized = true; + initialized_p = true; return REC_ERR_OKAY; } @@ -194,12 +206,6 @@ RecSignalManager(int id, const char *, size_t) RecDebug(DL_Debug, "local manager dropping signal %d", id); } -void -RecMessageRegister() -{ - lmgmt->registerMgmtCallback(MGMT_SIGNAL_LIBRECORDS, RecMessageRecvThis, NULL); -} - //------------------------------------------------------------------------- // RecMessageSend //------------------------------------------------------------------------- @@ -209,7 +215,7 @@ RecMessageSend(RecMessage * msg) { int msg_size; - if (!g_message_initialized) + if (!message_initialized_p) return REC_ERR_OKAY; // Make a copy of the record, but truncate it to the size actually used http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4343175/lib/records/RecMessage.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecMessage.cc b/lib/records/RecMessage.cc index a5ac467..ca8b352 100644 --- a/lib/records/RecMessage.cc +++ b/lib/records/RecMessage.cc @@ -30,34 +30,10 @@ #include "P_RecCore.h" #include "I_Layout.h" -static bool g_message_initialized = false; static RecMessageRecvCb g_recv_cb = NULL; static void *g_recv_cookie = NULL; //------------------------------------------------------------------------- -// RecMessageInit -//------------------------------------------------------------------------- - -int -RecMessageInit() -{ - if (g_message_initialized) { - return REC_ERR_OKAY; - } - - /* - * g_mode_type should be initialized by - * RecLocalInit() or RecProcessInit() earlier. - */ - ink_assert(g_mode_type != RECM_NULL); - - RecMessageRegister(); - - g_message_initialized = true; - return REC_ERR_OKAY; -} - -//------------------------------------------------------------------------- // RecMessageAlloc //------------------------------------------------------------------------- RecMessage * http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4343175/lib/records/RecProcess.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecProcess.cc b/lib/records/RecProcess.cc index 3d39d80..de47227 100644 --- a/lib/records/RecProcess.cc +++ b/lib/records/RecProcess.cc @@ -35,8 +35,8 @@ #include "mgmtapi.h" #include "ProcessManager.h" -static bool g_initialized = false; -static bool g_message_initialized = false; +// Marks whether the message handler has been initialized. +static bool message_initialized_p = false; static bool g_started = false; static EventNotify g_force_req_notify; static int g_rec_raw_stat_sync_interval_ms = REC_RAW_STAT_SYNC_INTERVAL_MS; @@ -408,7 +408,9 @@ struct sync_cont: public Continuation int RecProcessInit(RecModeT mode_type, Diags *_diags) { - if (g_initialized) { + static bool initialized_p = false; + + if (initialized_p) { return REC_ERR_OKAY; } @@ -437,26 +439,33 @@ RecProcessInit(RecModeT mode_type, Diags *_diags) } */ - g_initialized = true; + initialized_p = true; return REC_ERR_OKAY; } +void +RecMessageInit() +{ + ink_assert(g_mode_type != RECM_NULL); + pmgmt->registerMgmtCallback(MGMT_EVENT_LIBRECORDS, RecMessageRecvThis, NULL); + message_initialized_p = true; +} + //------------------------------------------------------------------------- // RecProcessInitMessage //------------------------------------------------------------------------- int RecProcessInitMessage(RecModeT mode_type) { - if (g_message_initialized) { - return REC_ERR_OKAY; - } + static bool initialized_p = false; - if (RecMessageInit() == REC_ERR_FAIL) { - return REC_ERR_FAIL; + if (initialized_p) { + return REC_ERR_OKAY; } + RecMessageInit(); if (RecMessageRegisterRecvCb(recv_message_cb__process, NULL)) { return REC_ERR_FAIL; } @@ -468,7 +477,7 @@ RecProcessInitMessage(RecModeT mode_type) g_force_req_notify.unlock(); } - g_message_initialized = true; + initialized_p = true; return REC_ERR_OKAY; } @@ -902,12 +911,6 @@ RecRegisterManagerCb(int _signal, RecManagerCb _fn, void *_data) return pmgmt->registerMgmtCallback(_signal, _fn, _data); } -void -RecMessageRegister() -{ - pmgmt->registerMgmtCallback(MGMT_EVENT_LIBRECORDS, RecMessageRecvThis, NULL); -} - //------------------------------------------------------------------------- // RecMessageSend //------------------------------------------------------------------------- @@ -917,7 +920,7 @@ RecMessageSend(RecMessage * msg) { int msg_size; - if (!g_message_initialized) + if (!message_initialized_p) return REC_ERR_OKAY; // Make a copy of the record, but truncate it to the size actually used
