[PATCH 3/4] LOG: handle closing unused logfiles better

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This fixes a bug where having a second log file will close
the previous one.

Signed-off-by: Angus Salkeld <asalkeld@xxxxxxxxxx>
---
 exec/logsys.c |   26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/exec/logsys.c b/exec/logsys.c
index 01e8783..d9ad129 100644
--- a/exec/logsys.c
+++ b/exec/logsys.c
@@ -149,11 +149,14 @@ static int logsys_config_file_set_unlocked (
 	char file_format[128];
 
 	if (logsys_loggers[subsysid].target_id > 0) {
-		/* TODO close file
-		logsys_filter_apply(subsysid,
-				    QB_LOG_FILTER_REMOVE,
-				    logsys_loggers[subsysid].target_id);
-		*/
+		int32_t f;
+		for (f = 0; f < logsys_loggers[subsysid].file_idx; f++) {
+			qb_log_filter_ctl(logsys_loggers[subsysid].target_id,
+				QB_LOG_FILTER_REMOVE,
+				QB_LOG_FILTER_FILE,
+				logsys_loggers[subsysid].files[f],
+				LOG_TRACE);
+		}
 	}
 
 	logsys_loggers[subsysid].dirty = QB_TRUE;
@@ -192,8 +195,17 @@ static int logsys_config_file_set_unlocked (
 	}
 
 	if (logsys_loggers[subsysid].target_id > 0) {
-		/* no one else is using this close it */
-		qb_log_file_close(logsys_loggers[subsysid].target_id);
+		int num_using_current = 0;
+		for (i = 0; i <= LOGSYS_MAX_SUBSYS_COUNT; i++) {
+			if (logsys_loggers[subsysid].target_id ==
+				logsys_loggers[i].target_id) {
+				num_using_current++;
+			}
+		}
+		if (num_using_current == 1) {
+			/* no one else is using this close it */
+			qb_log_file_close(logsys_loggers[subsysid].target_id);
+		}
 	}
 
 	logsys_loggers[subsysid].target_id = qb_log_file_open(file);
-- 
1.7.10.2

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux