Move release fence after the last global variable is modified 17/85317/4
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 24 Aug 2016 13:49:22 +0000 (15:49 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Tue, 30 Aug 2016 14:48:57 +0000 (07:48 -0700)
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

index fae54c2..f972274 100644 (file)
@@ -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);