[sheepdog] [PATCH] logger: fix a null reference bug

Liu Yuan namei.unix at gmail.com
Wed Dec 5 06:47:13 CET 2012


From: Liu Yuan <tailai.ly at taobao.com>

log_buf isn't shared any more, so we can't call log_flush() in sheep context.
let logger do the flushing work solve the problem.

Reported-by: Srer00t <sysecr00t at gmail.com>
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 lib/logger.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/logger.c b/lib/logger.c
index 3979bee..094b453 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -399,7 +399,9 @@ static notrace void logger(char *log_dir, char *outfile)
 		sleep(1);
 	}
 
+	log_flush();
 	free(log_buff);
+	free_logarea();
 	exit(0);
 }
 
@@ -451,8 +453,7 @@ notrace void log_close(void)
 		la->active = false;
 		waitpid(logger_pid, NULL, 0);
 
-		vprintf(SDOG_WARNING, "logger pid %d stopped\n", logger_pid);
-		log_flush();
+		syslog(LOG_WARNING, "logger pid %d stopped\n", logger_pid);
 		closelog();
 		free_logarea();
 	}
-- 
1.7.9.5




More information about the sheepdog mailing list