log agent did not protect the resource `unacked_invocations_ list` from accessing by multiple threads, so caused segmentation fault.
This patch introduces a mutex in order to synchronize the access to that common resource. --- src/log/agent/lga_client.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/log/agent/lga_client.h b/src/log/agent/lga_client.h index f5fa6faa4..c999d148e 100644 --- a/src/log/agent/lga_client.h +++ b/src/log/agent/lga_client.h @@ -174,11 +174,15 @@ class LogClient { // get acknowledgement from it. void KeepTrack(SaInvocationT inv, uint32_t ack_flags) { if (ack_flags != SA_LOG_RECORD_WRITE_ACK) return; + base::Lock scope_lock{mutex_unacked_list_}; unacked_invocations_.push_back(inv); } // Got an acknowledgment, so remove from the track list. - void RemoveTrack(SaInvocationT inv) { unacked_invocations_.remove(inv); } + void RemoveTrack(SaInvocationT inv) { + base::Lock scope_lock{mutex_unacked_list_}; + unacked_invocations_.remove(inv); + } void NotifyClientAboutLostInvocations() { for (const auto& i : unacked_invocations_) { @@ -196,6 +200,8 @@ class LogClient { SendMsgToMbx(msg, MDS_SEND_PRIORITY_HIGH); } + + base::Lock scope_lock{mutex_unacked_list_}; unacked_invocations_.clear(); } @@ -290,6 +296,10 @@ class LogClient { // If cluster goes to headless, log agent will inform to log client with // SA_AIS_ERR_TRY_AGAIN code for these invocations. std::list<SaInvocationT> unacked_invocations_{}; + + // To protect the `unacked_invocations_` list. + base::Mutex mutex_unacked_list_{}; + // LOG handle (derived from hdl-mngr) SaLogHandleT handle_; -- 2.17.1 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel