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

* Re: [PATCH] git-daemon: fix for rotating logs
  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-05-11 18:03 ` Johannes Schindelin
  1 sibling, 1 reply; 23+ messages in thread
From: Junio C Hamano @ 2008-04-28 16:29 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> 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.

Gaah, this is ugly.

Is this something all the daemons need to deal with?

> 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;
>  	}

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 16:29 ` Junio C Hamano
@ 2008-04-28 18:08   ` Johannes Schindelin
  2008-04-28 18:21     ` Miklos Vajna
  0 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2008-04-28 18:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Mon, 28 Apr 2008, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > 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.
> 
> Gaah, this is ugly.
> 
> Is this something all the daemons need to deal with?

I have no idea, but it seems to fix a real issue.

Ciao,
Dscho

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 18:08   ` Johannes Schindelin
@ 2008-04-28 18:21     ` Miklos Vajna
  2008-04-28 18:29       ` Mike Hommey
  0 siblings, 1 reply; 23+ messages in thread
From: Miklos Vajna @ 2008-04-28 18:21 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, git

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > > 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.
> > 
> > Gaah, this is ugly.
> > 
> > Is this something all the daemons need to deal with?
> 
> I have no idea, but it seems to fix a real issue.

logrotate supports sending a signal (typically SIGHUP) to the process
after it rotated the log. Couldn't we just re-open the log on SIGHUP?

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 18:21     ` Miklos Vajna
@ 2008-04-28 18:29       ` Mike Hommey
  2008-04-28 18:37         ` Johannes Schindelin
  2008-04-29  6:17         ` Andreas Ericsson
  0 siblings, 2 replies; 23+ messages in thread
From: Mike Hommey @ 2008-04-28 18:29 UTC (permalink / raw)
  To: Johannes Schindelin, Junio C Hamano, git

On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:
> On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > > > 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.
> > > 
> > > Gaah, this is ugly.
> > > 
> > > Is this something all the daemons need to deal with?
> > 
> > I have no idea, but it seems to fix a real issue.
> 
> logrotate supports sending a signal (typically SIGHUP) to the process
> after it rotated the log. Couldn't we just re-open the log on SIGHUP?

Isn't the problem that git-daemon loses its connection to the syslog
daemon when logrotate sighups syslog?

Mike

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 18:29       ` Mike Hommey
@ 2008-04-28 18:37         ` Johannes Schindelin
  2008-04-28 19:00           ` Miklos Vajna
  2008-04-29  6:17         ` Andreas Ericsson
  1 sibling, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2008-04-28 18:37 UTC (permalink / raw)
  To: Mike Hommey; +Cc: Junio C Hamano, git

Hi,

On Mon, 28 Apr 2008, Mike Hommey wrote:

> On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:
> > On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > > > > 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.
> > > > 
> > > > Gaah, this is ugly.
> > > > 
> > > > Is this something all the daemons need to deal with?
> > > 
> > > I have no idea, but it seems to fix a real issue.
> > 
> > logrotate supports sending a signal (typically SIGHUP) to the process 
> > after it rotated the log. Couldn't we just re-open the log on SIGHUP?
> 
> Isn't the problem that git-daemon loses its connection to the syslog 
> daemon when logrotate sighups syslog?

I have no idea, but other programs must have the same problem.  I should 
have shown some diligence and researched that.  Will do so now.

Ciao,
Dscho

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

* Re: [PATCH] git-daemon: fix for rotating logs
  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
  0 siblings, 2 replies; 23+ messages in thread
From: Miklos Vajna @ 2008-04-28 19:00 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Mike Hommey, Junio C Hamano, git

[-- Attachment #1: Type: text/plain, Size: 558 bytes --]

On Mon, Apr 28, 2008 at 07:37:54PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > Isn't the problem that git-daemon loses its connection to the syslog 
> > daemon when logrotate sighups syslog?

Right, but logrotate could send SIGHUP to git-daemon as well.

> I have no idea, but other programs must have the same problem.  I should 
> have shown some diligence and researched that.  Will do so now.

I don't say that just one example justifies me, but here is an example:
icald (google://openlog+sighup 2nd result) does this.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 19:00           ` Miklos Vajna
@ 2008-04-28 19:24             ` Johannes Schindelin
  2008-04-28 19:28             ` Stephen R. van den Berg
  1 sibling, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2008-04-28 19:24 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: Mike Hommey, Junio C Hamano, git

Hi,

On Mon, 28 Apr 2008, Miklos Vajna wrote:

> On Mon, Apr 28, 2008 at 07:37:54PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > > Isn't the problem that git-daemon loses its connection to the syslog 
> > > daemon when logrotate sighups syslog?
> 
> Right, but logrotate could send SIGHUP to git-daemon as well.

Probably.  But I do not understand how git-daemon just hangs when trying 
to close() something from within syslog().  Maybe my analysis is 
completely wrong, and I should do something completely different.

Ciao,
Dscho

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

* Re: [PATCH] git-daemon: fix for rotating logs
  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
  1 sibling, 1 reply; 23+ messages in thread
From: Stephen R. van den Berg @ 2008-04-28 19:28 UTC (permalink / raw)
  To: git

Miklos Vajna wrote:
>Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>> > Isn't the problem that git-daemon loses its connection to the syslog 
>> > daemon when logrotate sighups syslog?

No.

>Right, but logrotate could send SIGHUP to git-daemon as well.

It could, but that's the reason one uses the openlog(3) interface to
syslog, to centralise logfilemanagement and *not* having to deal with
the intricacies of logfile rotation and the like.  So it doesn't need
to.  When you need logfile rotation, you're better off with using
openlog(3), and doing that the proper way means *NOT* closing and
reopening that everytime.

>> I have no idea, but other programs must have the same problem.  I should 

They don't.  Your patch fixes the wrong problem.  Please don't fix
something that wasn't broken in the first place.

>> have shown some diligence and researched that.  Will do so now.

>I don't say that just one example justifies me, but here is an example:
>icald (google://openlog+sighup 2nd result) does this.

N.B. I've never had to close and reopen the openlog(3) syslog interface
in any of the daemons I've written.
The example you refer to of icald is where it directly writes to a
logfile, which is *not* what this patch was about, so please do not use
it as justification.
-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg.

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

* Re: [PATCH] git-daemon: fix for rotating logs
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2008-04-28 19:53 UTC (permalink / raw)
  To: Stephen R. van den Berg; +Cc: git

Hi,

since you seem to be very new to this list: we really appreciate a 
Reply-to-all here.

On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:

> >> I have no idea, but other programs must have the same problem.  I 
> >> should
> 
> They don't.  Your patch fixes the wrong problem.  Please don't fix 
> something that wasn't broken in the first place.

So do you have any ideas what is happening there?  It seems that after 
logrotate does its thing, syslog() is stuck in the close() call.

Any constructive help is very much appreciated.

Ciao,
Dscho

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 19:53               ` Johannes Schindelin
@ 2008-04-28 20:43                 ` Stephen R. van den Berg
  2008-04-28 20:53                   ` Johannes Schindelin
  0 siblings, 1 reply; 23+ messages in thread
From: Stephen R. van den Berg @ 2008-04-28 20:43 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin wrote:
>since you seem to be very new to this list: we really appreciate a 
>Reply-to-all here.

I see.  I normally consider that bad form (maybe my age shows ;-);
but if people insist here, no problem.

>On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:

>> >> I have no idea, but other programs must have the same problem.  I 
>> >> should

>So do you have any ideas what is happening there?  It seems that after 
>logrotate does its thing, syslog() is stuck in the close() call.

Erm, just so I understand the problem:
- git-daemon is configured to use syslog(3) to log
- git-daemon uses openlog(3)
- git-daemon logs happily for a while
- rotatelog rotates logfiles in /var/log and communicates with syslogd
  to make sure syslogd starts new logfiles in /var/log
- And then git-daemon hangs on which system/library call?
-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg.

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

* Re: [PATCH] git-daemon: fix for rotating logs
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2008-04-28 20:53 UTC (permalink / raw)
  To: Stephen R. van den Berg; +Cc: git

Hi,

On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:

> Johannes Schindelin wrote:
> 
> >On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:
> 
> >> >> I have no idea, but other programs must have the same problem.  I 
> >> >> should
> 
> >So do you have any ideas what is happening there?  It seems that after 
> >logrotate does its thing, syslog() is stuck in the close() call.
> 
> Erm, just so I understand the problem:
> - git-daemon is configured to use syslog(3) to log
> - git-daemon uses openlog(3)
> - git-daemon logs happily for a while
> - rotatelog rotates logfiles in /var/log and communicates with syslogd
>   to make sure syslogd starts new logfiles in /var/log
> - And then git-daemon hangs on which system/library call?

It seems that this happens, yes.

Ciao,
Dscho

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 20:53                   ` Johannes Schindelin
@ 2008-04-28 21:00                     ` Stephen R. van den Berg
  2008-04-28 21:09                       ` Johannes Schindelin
  0 siblings, 1 reply; 23+ messages in thread
From: Stephen R. van den Berg @ 2008-04-28 21:00 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin wrote:
>On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:
>> - git-daemon logs happily for a while
>> - rotatelog rotates logfiles in /var/log and communicates with syslogd
>>   to make sure syslogd starts new logfiles in /var/log
>> - And then git-daemon hangs on which system/library call?

>It seems that this happens, yes.

Could you hang an strace off of git-daemon and check what system call it
hangs on at that point in time?
-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg.

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

* Re: [PATCH] git-daemon: fix for rotating logs
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2008-04-28 21:09 UTC (permalink / raw)
  To: Stephen R. van den Berg; +Cc: git

Hi,

On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:

> Johannes Schindelin wrote:
> >On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:
> >> - git-daemon logs happily for a while
> >> - rotatelog rotates logfiles in /var/log and communicates with syslogd
> >>   to make sure syslogd starts new logfiles in /var/log
> >> - And then git-daemon hangs on which system/library call?
> 
> >It seems that this happens, yes.
> 
> Could you hang an strace off of git-daemon and check what system call it
> hangs on at that point in time?

I can do better than that.  I attached to the process, and like I said, it 
hung in close().

Ciao,
Dscho

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 21:09                       ` Johannes Schindelin
@ 2008-04-28 21:13                         ` Stephen R. van den Berg
  2008-04-28 21:23                           ` Johannes Schindelin
  0 siblings, 1 reply; 23+ messages in thread
From: Stephen R. van den Berg @ 2008-04-28 21:13 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin wrote:
>On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:
>> Johannes Schindelin wrote:
>> >On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:
>> >> - rotatelog rotates logfiles in /var/log and communicates with syslogd
>> >>   to make sure syslogd starts new logfiles in /var/log
>> >> - And then git-daemon hangs on which system/library call?

>I can do better than that.  I attached to the process, and like I said, it 
>hung in close().

On which descriptor?  (I.e. what does the descriptor point to?)
-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg.

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

* Re: [PATCH] git-daemon: fix for rotating logs
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2008-04-28 21:23 UTC (permalink / raw)
  To: Stephen R. van den Berg; +Cc: git

Hi,

On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:

> Johannes Schindelin wrote:
> >On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:
> >> Johannes Schindelin wrote:
> >> >On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:
> >> >> - rotatelog rotates logfiles in /var/log and communicates with syslogd
> >> >>   to make sure syslogd starts new logfiles in /var/log
> >> >> - And then git-daemon hangs on which system/library call?
> 
> >I can do better than that.  I attached to the process, and like I said, it 
> >hung in close().
> 
> On which descriptor?  (I.e. what does the descriptor point to?)

Sorry, that I don't remember, but I strongly suspect the syslog 
descriptor, since the backtrace showed "syslog()" a few levels up of 
close().

Ciao,
Dscho

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 21:23                           ` Johannes Schindelin
@ 2008-04-28 23:16                             ` Stephen R. van den Berg
  0 siblings, 0 replies; 23+ messages in thread
From: Stephen R. van den Berg @ 2008-04-28 23:16 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin wrote:
>On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:
>> >I can do better than that.  I attached to the process, and like I said, it 
>> >hung in close().

>> On which descriptor?  (I.e. what does the descriptor point to?)

>Sorry, that I don't remember, but I strongly suspect the syslog 
>descriptor, since the backtrace showed "syslog()" a few levels up of 
>close().

AFAICT, sending SIGHUP to syslogd doesn't cause the /dev/log pipe to be
closed, therefore there shouldn't be any closing of that /dev/log pipe.
So if you can reproduce it, please report which filedescriptor it is
trying to close.
-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg.

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 18:29       ` Mike Hommey
  2008-04-28 18:37         ` Johannes Schindelin
@ 2008-04-29  6:17         ` Andreas Ericsson
  2008-04-29 10:54           ` Johannes Schindelin
  1 sibling, 1 reply; 23+ messages in thread
From: Andreas Ericsson @ 2008-04-29  6:17 UTC (permalink / raw)
  To: Mike Hommey; +Cc: Johannes Schindelin, Junio C Hamano, git

Mike Hommey wrote:
> On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:
>> On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>>>>> 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.
>>>> Gaah, this is ugly.
>>>>
>>>> Is this something all the daemons need to deal with?
>>> I have no idea, but it seems to fix a real issue.
>> logrotate supports sending a signal (typically SIGHUP) to the process
>> after it rotated the log. Couldn't we just re-open the log on SIGHUP?
> 
> Isn't the problem that git-daemon loses its connection to the syslog
> daemon when logrotate sighups syslog?
> 

It really shouldn't. The connection to the syslog daemon is just a
unix socket (/dev/log) which is used to send whatever passes for
UDP packets on unix domain sockets. Since the socket isn't re-created
by syslogd (well, a sane syslogd anyways), but rather just open()'ed
for reading, no program should ever need to reconnect.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-29  6:17         ` Andreas Ericsson
@ 2008-04-29 10:54           ` Johannes Schindelin
  2008-04-29 11:00             ` Andreas Ericsson
  0 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2008-04-29 10:54 UTC (permalink / raw)
  To: Andreas Ericsson; +Cc: Mike Hommey, Junio C Hamano, git

Hi,

On Tue, 29 Apr 2008, Andreas Ericsson wrote:

> Mike Hommey wrote:
> > On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:
> > > On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin
> > > <Johannes.Schindelin@gmx.de> wrote:
> > > > > > 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.
> > > > > Gaah, this is ugly.
> > > > >
> > > > > Is this something all the daemons need to deal with?
> > > > I have no idea, but it seems to fix a real issue.
> > > logrotate supports sending a signal (typically SIGHUP) to the process
> > > after it rotated the log. Couldn't we just re-open the log on SIGHUP?
> > 
> > Isn't the problem that git-daemon loses its connection to the syslog
> > daemon when logrotate sighups syslog?
> > 
> 
> It really shouldn't. The connection to the syslog daemon is just a
> unix socket (/dev/log) which is used to send whatever passes for
> UDP packets on unix domain sockets. Since the socket isn't re-created
> by syslogd (well, a sane syslogd anyways), but rather just open()'ed
> for reading, no program should ever need to reconnect.

What can I say?  The problem just went away with my workaround.  Is it 
possible that I have to catch SIGHUP, and closelog() && openlog()?  But 
why do other daemons seem to not have that problem at all?

Ciao,
Dscho

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-29 10:54           ` Johannes Schindelin
@ 2008-04-29 11:00             ` Andreas Ericsson
  2008-04-29 15:16               ` Johannes Schindelin
  0 siblings, 1 reply; 23+ messages in thread
From: Andreas Ericsson @ 2008-04-29 11:00 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Mike Hommey, Junio C Hamano, git

Johannes Schindelin wrote:
> Hi,
> 
> On Tue, 29 Apr 2008, Andreas Ericsson wrote:
> 
>> Mike Hommey wrote:
>>> On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:
>>>> On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin
>>>> <Johannes.Schindelin@gmx.de> wrote:
>>>>>>> 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.
>>>>>> Gaah, this is ugly.
>>>>>>
>>>>>> Is this something all the daemons need to deal with?
>>>>> I have no idea, but it seems to fix a real issue.
>>>> logrotate supports sending a signal (typically SIGHUP) to the process
>>>> after it rotated the log. Couldn't we just re-open the log on SIGHUP?
>>> Isn't the problem that git-daemon loses its connection to the syslog
>>> daemon when logrotate sighups syslog?
>>>
>> It really shouldn't. The connection to the syslog daemon is just a
>> unix socket (/dev/log) which is used to send whatever passes for
>> UDP packets on unix domain sockets. Since the socket isn't re-created
>> by syslogd (well, a sane syslogd anyways), but rather just open()'ed
>> for reading, no program should ever need to reconnect.
> 
> What can I say?  The problem just went away with my workaround.  Is it 
> possible that I have to catch SIGHUP, and closelog() && openlog()?  But 
> why do other daemons seem to not have that problem at all?
> 

Other daemons don't get SIGHUP'ed when logs are rotated. I think something
else is going on there.

What syslogd are you using? Perhaps it insists on re-creating the socket.
That might cause the behaviour you're seeing, but then you should probably
see it in a ton of other daemons as well.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-29 11:00             ` Andreas Ericsson
@ 2008-04-29 15:16               ` Johannes Schindelin
  2008-04-29 17:58                 ` Stephen R. van den Berg
  0 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2008-04-29 15:16 UTC (permalink / raw)
  To: Andreas Ericsson; +Cc: Mike Hommey, Junio C Hamano, git

Hi,

On Tue, 29 Apr 2008, Andreas Ericsson wrote:

> Johannes Schindelin wrote:
> 
> > On Tue, 29 Apr 2008, Andreas Ericsson wrote:
> > 
> > > Mike Hommey wrote:
> > > > On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:
> > > > > On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin 
> > > > > <Johannes.Schindelin@gmx.de> wrote:
> > > > > > > > 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.
> > > > > > > Gaah, this is ugly.
> > > > > > >
> > > > > > > Is this something all the daemons need to deal with?
> > > > > > I have no idea, but it seems to fix a real issue.
> > > > > logrotate supports sending a signal (typically SIGHUP) to the 
> > > > > process after it rotated the log. Couldn't we just re-open the 
> > > > > log on SIGHUP?
> > > > Isn't the problem that git-daemon loses its connection to the 
> > > > syslog daemon when logrotate sighups syslog?
> > > >
> > > It really shouldn't. The connection to the syslog daemon is just a 
> > > unix socket (/dev/log) which is used to send whatever passes for UDP 
> > > packets on unix domain sockets. Since the socket isn't re-created by 
> > > syslogd (well, a sane syslogd anyways), but rather just open()'ed 
> > > for reading, no program should ever need to reconnect.
> > 
> > What can I say?  The problem just went away with my workaround.  Is it 
> > possible that I have to catch SIGHUP, and closelog() && openlog()?  
> > But why do other daemons seem to not have that problem at all?
> > 
> 
> Other daemons don't get SIGHUP'ed when logs are rotated. I think 
> something else is going on there.
> 
> What syslogd are you using? Perhaps it insists on re-creating the 
> socket. That might cause the behaviour you're seeing, but then you 
> should probably see it in a ton of other daemons as well.

This is sysklogd from Ubuntu, compiled for amd64.  The timestamp on 
/dev/log is older than a month.

Thanks,
Dscho

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-29 15:16               ` Johannes Schindelin
@ 2008-04-29 17:58                 ` Stephen R. van den Berg
  0 siblings, 0 replies; 23+ messages in thread
From: Stephen R. van den Berg @ 2008-04-29 17:58 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Andreas Ericsson, Mike Hommey, Junio C Hamano, git

Johannes Schindelin wrote:
>On Tue, 29 Apr 2008, Andreas Ericsson wrote:
>> What syslogd are you using? Perhaps it insists on re-creating the 
>> socket. That might cause the behaviour you're seeing, but then you 
>> should probably see it in a ton of other daemons as well.

Recreating the socket should not cause this to happen either, because
the git-daemon will still hold on to the old inode (even after the file
has been removed).

>This is sysklogd from Ubuntu, compiled for amd64.  The timestamp on 
>/dev/log is older than a month.

I'd still recommend trying to reproduce the problem, then find out which
filedescriptor/file the close is hanging on.
-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg.

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

* Re: [PATCH] git-daemon: fix for rotating logs
  2008-04-28 14:24 [PATCH] git-daemon: fix for rotating logs Johannes Schindelin
  2008-04-28 16:29 ` Junio C Hamano
@ 2008-05-11 18:03 ` Johannes Schindelin
  1 sibling, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2008-05-11 18:03 UTC (permalink / raw)
  To: git, gitster

Hi,

On Mon, 28 Apr 2008, Johannes Schindelin wrote:

> 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.

Actually, the culprit were _not_ rotating logs.  At least not really.  
syslog() is not supposed to be called from a signal handler.  In 
git-daemon, it is, from child_handler(), but only when called with 
--verbose (and --syslog, or --detach).  Bummer.

Sorry for my wrong analysis,
Dscho

^ permalink raw reply	[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).