diff options
-rw-r--r-- | src/resource-monitor/logging.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/resource-monitor/logging.c b/src/resource-monitor/logging.c index f487752a..0d297120 100644 --- a/src/resource-monitor/logging.c +++ b/src/resource-monitor/logging.c @@ -905,11 +905,9 @@ int logging_read_foreach(char *name, char *appid, char *pkgid, } /* search from cache */ - if (!g_queue_is_empty(module->cache)) { - pthread_mutex_lock(&(module->cache_mutex)); - g_queue_foreach(module->cache, (GFunc)logging_cache_search, (gpointer)&search); - pthread_mutex_unlock(&(module->cache_mutex)); - } + pthread_mutex_lock(&(module->cache_mutex)); + g_queue_foreach(module->cache, (GFunc)logging_cache_search, (gpointer)&search); + pthread_mutex_unlock(&(module->cache_mutex)); return RESOURCED_ERROR_NONE; } @@ -1042,16 +1040,14 @@ int logging_modify_appid(char *module_name, char *old_appid, char *new_appid, in } /* Modify cache */ - if (!g_queue_is_empty(module->cache)) { - pthread_mutex_lock(&(module->cache_mutex)); - for (i = 0; i < g_queue_get_length(module->cache); i++) { - entry = (struct logging_table_form *)g_queue_peek_nth( - module->cache, i); - if (entry->uid == uid && !strncmp(entry->appid, old_appid, strlen(old_appid))) - snprintf(entry->appid, MAX_APPID_LENGTH, "%s", new_appid); - } - pthread_mutex_unlock(&(module->cache_mutex)); + pthread_mutex_lock(&(module->cache_mutex)); + for (i = 0; i < g_queue_get_length(module->cache); i++) { + entry = (struct logging_table_form *)g_queue_peek_nth( + module->cache, i); + if (entry->uid == uid && !strncmp(entry->appid, old_appid, strlen(old_appid))) + snprintf(entry->appid, MAX_APPID_LENGTH, "%s", new_appid); } + pthread_mutex_unlock(&(module->cache_mutex)); /* Modify DB */ switch (module->db_type) { |