Added mutex lock for avoiding the data race condition 49/305649/2 accepted/tizen/unified/20240207.171607 accepted/tizen/unified/x/20240208.022950
authordyamy-lee <dyamy.lee@samsung.com>
Tue, 6 Feb 2024 03:17:08 +0000 (12:17 +0900)
committerdyamy-lee <dyamy.lee@samsung.com>
Tue, 6 Feb 2024 03:18:38 +0000 (12:18 +0900)
When it updates g_config_info, it needs mutex lock for preventing the data race condition.
When it accesses g_app_list, it needs mutex lock for preventing the data race condition.

Change-Id: I7b094b377a81e1e4fa35bf6cf6332a6baef8f83e

common/tts_config_parser.c
server/ttsd_data.cpp

index 901b09a..d489336 100644 (file)
@@ -553,7 +553,9 @@ int tts_parser_load_config(void)
                cur = cur->next;
        }
 
+       pthread_mutex_lock(&g_config_info_mutex);
        g_config_info = temp;
+       pthread_mutex_unlock(&g_config_info_mutex);
        g_config_doc = doc;
 
        if (true == is_default_open) {
index efca767..bce9b64 100644 (file)
@@ -299,6 +299,7 @@ int ttsd_data_is_client(unsigned int uid)
 
 int ttsd_data_get_client_count()
 {
+       lock_guard<mutex> lock(g_app_data_mutex);
        int num_client = g_app_list.size();
        SLOG(LOG_INFO, tts_tag(), "[DATA INFO] Number of clients(%d)", num_client);