git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-daemon: fix for rotating logs
@ 2008-04-28 14:24 Johannes Schindelin
  2008-04-28 16:29 ` Junio C Hamano
  2008-05-11 18:03 ` Johannes Schindelin
  0 siblings, 2 replies; 23+ messages in thread
From: Johannes Schindelin @ 2008-04-28 14:24 UTC (permalink / raw)
  To: git, gitster


With rotating logs, there is a problem when the syslog is opened only once 
(in the beginning).  So open the log everytime we write something, and 
close it directly after writing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 daemon.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/daemon.c b/daemon.c
index 2b4a6f1..a887c72 100644
--- a/daemon.c
+++ b/daemon.c
@@ -90,7 +90,9 @@ static void logreport(int priority, const char *err, va_list params)
 	msglen = vsnprintf(buf + buflen, maxlen, err, params);
 
 	if (log_syslog) {
+		openlog("git-daemon", 0, LOG_DAEMON);
 		syslog(priority, "%s", buf);
+		closelog();
 		return;
 	}
 
@@ -767,8 +769,11 @@ static void child_handler(int signo)
 				const char *dead = "";
 				if (!WIFEXITED(status) || WEXITSTATUS(status) > 0)
 					dead = " (with error)";
-				if (log_syslog)
+				if (log_syslog) {
+					openlog("git-daemon", 0, LOG_DAEMON);
 					syslog(LOG_INFO, "[%d] Disconnected%s", pid, dead);
+					closelog();
+				}
 				else
 					fprintf(stderr, "[%d] Disconnected%s\n", pid, dead);
 			}
@@ -1149,10 +1154,8 @@ int main(int argc, char **argv)
 		usage(daemon_usage);
 	}
 
-	if (log_syslog) {
-		openlog("git-daemon", 0, LOG_DAEMON);
+	if (log_syslog)
 		set_die_routine(daemon_die);
-	}
 
 	if (inetd_mode && (group_name || user_name))
 		die("--user and --group are incompatible with --inetd");
-- 
1.5.4.4.GIT

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2008-05-11 18:04 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-28 14:24 [PATCH] git-daemon: fix for rotating logs Johannes Schindelin
2008-04-28 16:29 ` Junio C Hamano
2008-04-28 18:08   ` Johannes Schindelin
2008-04-28 18:21     ` Miklos Vajna
2008-04-28 18:29       ` Mike Hommey
2008-04-28 18:37         ` Johannes Schindelin
2008-04-28 19:00           ` Miklos Vajna
2008-04-28 19:24             ` Johannes Schindelin
2008-04-28 19:28             ` Stephen R. van den Berg
2008-04-28 19:53               ` Johannes Schindelin
2008-04-28 20:43                 ` Stephen R. van den Berg
2008-04-28 20:53                   ` Johannes Schindelin
2008-04-28 21:00                     ` Stephen R. van den Berg
2008-04-28 21:09                       ` Johannes Schindelin
2008-04-28 21:13                         ` Stephen R. van den Berg
2008-04-28 21:23                           ` Johannes Schindelin
2008-04-28 23:16                             ` Stephen R. van den Berg
2008-04-29  6:17         ` Andreas Ericsson
2008-04-29 10:54           ` Johannes Schindelin
2008-04-29 11:00             ` Andreas Ericsson
2008-04-29 15:16               ` Johannes Schindelin
2008-04-29 17:58                 ` Stephen R. van den Berg
2008-05-11 18:03 ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).