From 98c5be46d3870e726fea0ae569c9572c2eea3810 Mon Sep 17 00:00:00 2001 From: Krzysztof Jackiewicz Date: Wed, 24 Aug 2016 15:49:22 +0200 Subject: [PATCH] Move release fence after the last global variable is modified The global variable g_tid_attr_current_map is being read by other threads. To guarantee that its modification in main thread is visible in other threads the release fence should be set *after* the modification. Change-Id: Iff7bdd4053baa86f13a0465e52c599396e2dcb8f --- src/client/client-security-manager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client/client-security-manager.cpp b/src/client/client-security-manager.cpp index fae54c2..f972274 100644 --- a/src/client/client-security-manager.cpp +++ b/src/client/client-security-manager.cpp @@ -549,8 +549,6 @@ static inline int security_manager_sync_threads_internal(const char *app_name) return SECURITY_MANAGER_ERROR_UNKNOWN; } - std::atomic_thread_fence(std::memory_order_release); - struct sigaction act; struct sigaction old; memset(&act, '\0', sizeof(act)); @@ -590,8 +588,13 @@ static inline int security_manager_sync_threads_internal(const char *app_name) continue; g_tid_attr_current_map[tid] = "/proc/self/task/" + std::to_string(tid) + "/attr/current"; + } + + std::atomic_thread_fence(std::memory_order_release); + + for (auto const& t_pair : g_tid_attr_current_map) { sent_signals_count++; - tgkill(cur_pid, tid); + tgkill(cur_pid, t_pair.first); } LogDebug("sent_signals_count: " << sent_signals_count); -- 2.7.4