Count the log clients base on the user counter. --- src/log/agent/lga_agent.cc | 14 +++++--------- src/log/agent/lga_agent.h | 3 --- src/log/agent/lga_util.cc | 9 +++++++++ src/log/agent/lga_util.h | 1 + 4 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/src/log/agent/lga_agent.cc b/src/log/agent/lga_agent.cc index 33130b160..e84ea3a28 100644 --- a/src/log/agent/lga_agent.cc +++ b/src/log/agent/lga_agent.cc @@ -451,6 +451,9 @@ SaAisErrorT LogAgent::saLogInitialize(SaLogHandleT* logHandle, // server and is not conflicting with auto recovery //< + // Increase client counter + lga_increase_user_counter(); + // Initiate the client in the agent and if first client also start MDS rc = lga_startup(); if (rc != NCSCC_RC_SUCCESS) { @@ -460,12 +463,10 @@ SaAisErrorT LogAgent::saLogInitialize(SaLogHandleT* logHandle, } else { ais_rc = SA_AIS_ERR_LIBRARY; } + lga_decrease_user_counter(); return ais_rc; } - // Increase client counter - lga_increase_user_counter(); - // Populate the message to be sent to the LGS memset(&i_msg, 0, sizeof(lgsv_msg_t)); i_msg.type = LGSV_LGA_API_MSG; @@ -628,11 +629,6 @@ SaAisErrorT LogAgent::saLogDispatch(SaLogHandleT logHandle, return ais_rc; } -size_t LogAgent::CountClient() { - ScopeLock scopeLock(mutex_); - return client_list_.size(); -} - SaAisErrorT LogAgent::SendFinalizeMsg(uint32_t client_id) { uint32_t mds_rc; lgsv_msg_t msg, *o_msg = nullptr; @@ -760,7 +756,7 @@ SaAisErrorT LogAgent::saLogFinalize(SaLogHandleT logHandle) { } } - if (CountClient() == 0) { + if (lga_get_number_of_user() == 0) { // Stop recovery thread if it's running stop_recovery2_thread(); // Shutdown the agent diff --git a/src/log/agent/lga_agent.h b/src/log/agent/lga_agent.h index 55632684a..957adc716 100644 --- a/src/log/agent/lga_agent.h +++ b/src/log/agent/lga_agent.h @@ -198,9 +198,6 @@ class LogAgent { // True if there is no LOG server at all (headless) bool is_no_log_server() const; - // Count number of clients in agent - size_t CountClient(); - // Form finalize Msg and send to MDS SaAisErrorT SendFinalizeMsg(uint32_t client_id); diff --git a/src/log/agent/lga_util.cc b/src/log/agent/lga_util.cc index 2a3347a76..30920b7aa 100644 --- a/src/log/agent/lga_util.cc +++ b/src/log/agent/lga_util.cc @@ -162,6 +162,15 @@ void lga_decrease_user_counter(void) { --client_counter; } +/** + * Get number of user + */ +unsigned int lga_get_number_of_user(void){ + ScopeLock lock(init_lock); + + return client_counter; +} + /** * Check if the name is valid or not. */ diff --git a/src/log/agent/lga_util.h b/src/log/agent/lga_util.h index 179c6ae9d..4858e758a 100644 --- a/src/log/agent/lga_util.h +++ b/src/log/agent/lga_util.h @@ -26,6 +26,7 @@ unsigned int lga_startup(); unsigned int lga_shutdown(); void lga_increase_user_counter(void); void lga_decrease_user_counter(void); +unsigned int lga_get_number_of_user(void); bool lga_is_extended_name_valid(const SaNameT* name); -- 2.25.1 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel