grap log lock when initializing a destination
This commit is contained in:
+11
-5
@@ -118,20 +118,26 @@ static inline int uc_ll_2_syslog(enum UC_LOG_LEVEL l)
|
||||
return LOG_INFO;
|
||||
}
|
||||
|
||||
//Note, this grabs the global lock
|
||||
static int uc_log_init_settings(struct uc_log_destination *dest)
|
||||
{
|
||||
int i;
|
||||
int rc = -1;
|
||||
|
||||
pthread_mutex_lock(&g_log_lock);
|
||||
|
||||
dest->module_settings = calloc(g_modules.cnt, sizeof *dest->module_settings);
|
||||
if (dest->module_settings == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dest->module_settings != NULL) {
|
||||
for (i = 0; i < g_modules.cnt; i++) {
|
||||
dest->module_settings[i].log_level = g_modules.mods[i].log_level;
|
||||
}
|
||||
|
||||
return 0;
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&g_log_lock);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct uc_log_destination *uc_log_new_stderr(int log_level, int log_location)
|
||||
|
||||
Reference in New Issue
Block a user