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