Refactor uc_log_reopen_files
This commit is contained in:
+17
-8
@@ -58,6 +58,7 @@ static const struct uc_log_module unknown_module = {
|
||||
//All destinations. The log_lock must be held while accessing
|
||||
//this list an anything contained within it.
|
||||
static SLIST_HEAD(, uc_log_destination) destinations;
|
||||
static int uc_log_reopen_file(struct uc_log_destination *dest);
|
||||
|
||||
inline const char *uc_ll_2_str(enum UC_LOG_LEVEL l)
|
||||
{
|
||||
@@ -250,17 +251,10 @@ void uc_log_delete_destination(struct uc_log_destination *dest)
|
||||
pthread_mutex_unlock(&log_lock);
|
||||
}
|
||||
|
||||
int uc_log_reopen_files(void)
|
||||
static int uc_log_reopen_file(struct uc_log_destination *dest)
|
||||
{
|
||||
struct uc_log_destination *dest;
|
||||
int rc = 0;
|
||||
|
||||
pthread_mutex_lock(&log_lock);
|
||||
|
||||
SLIST_FOREACH(dest, &destinations, entry) {
|
||||
|
||||
if (dest->dest_type == UC_LDEST_FILE) {
|
||||
|
||||
if (dest->type.file.file != NULL) {
|
||||
fclose(dest->type.file.file);
|
||||
dest->type.file.file = NULL;
|
||||
@@ -272,6 +266,21 @@ int uc_log_reopen_files(void)
|
||||
if (dest->type.file.file == NULL)
|
||||
rc = errno;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int uc_log_reopen_files(void)
|
||||
{
|
||||
struct uc_log_destination *dest;
|
||||
int rc = 0;
|
||||
|
||||
pthread_mutex_lock(&log_lock);
|
||||
|
||||
SLIST_FOREACH(dest, &destinations, entry) {
|
||||
|
||||
if (dest->dest_type == UC_LDEST_FILE) {
|
||||
rc = uc_log_reopen_file(dest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user