[sheepdog] [PATCH stable-0.7 1/3] logger: remove unnecessary lock for log rotation

Hitoshi Mitake mitake.hitoshi at gmail.com
Tue Dec 10 15:29:04 CET 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

The logger process runs with one thread, so no need for
pthread_mutex_lock.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 lib/logger.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/lib/logger.c b/lib/logger.c
index 7c9e540..0e55569 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -126,8 +126,6 @@ static char *log_buff;
 
 static int64_t max_logsize = 500 * 1024 * 1024;  /*500MB*/
 
-static pthread_mutex_t logsize_lock = PTHREAD_MUTEX_INITIALIZER;
-
 static const char *format_thread_name(char *str, size_t size, const char *name,
 				      int idx)
 {
@@ -552,7 +550,6 @@ static void logger(char *log_dir, char *outfile)
 		if (max_logsize) {
 			off_t offset;
 
-			pthread_mutex_lock(&logsize_lock);
 			offset = lseek(log_fd, 0, SEEK_END);
 			if (offset < 0) {
 				syslog(LOG_ERR, "sheep log error\n");
@@ -561,7 +558,6 @@ static void logger(char *log_dir, char *outfile)
 				if (log_size >= max_logsize)
 					rotate_log();
 			}
-			pthread_mutex_unlock(&logsize_lock);
 		}
 
 		sleep(1);
-- 
1.8.1.2




More information about the sheepdog mailing list