You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pe...@apache.org on 2023/12/01 12:29:31 UTC

(celix) 08/11: [CID 331918]Fix data race in dm_example.

This is an automated email from the ASF dual-hosted git repository.

pengzheng pushed a commit to branch support/2.4
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 18f181d460bc9b30baf384017da68d66e55c4337
Author: PengZheng <ho...@gmail.com>
AuthorDate: Thu Nov 23 18:52:40 2023 +0800

    [CID 331918]Fix data race in dm_example.
    
    (cherry picked from commit 9d046de132deabf9b3f9d88eaa58b672cd7a0499)
---
 examples/celix-examples/dm_example/phase2a/src/phase2a_cmp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/examples/celix-examples/dm_example/phase2a/src/phase2a_cmp.c b/examples/celix-examples/dm_example/phase2a/src/phase2a_cmp.c
index f6884984..07df43cb 100644
--- a/examples/celix-examples/dm_example/phase2a/src/phase2a_cmp.c
+++ b/examples/celix-examples/dm_example/phase2a/src/phase2a_cmp.c
@@ -112,6 +112,8 @@ static void *phase2a_thread(void *data) {
 }
 
 int phase2a_getData(phase2a_cmp_t *cmp, double *data) {
+    celixThreadMutex_lock(&cmp->mutex);
     *data = cmp->currentValue;
+    celixThreadMutex_unlock(&cmp->mutex);
     return 0;
 }