{"thread":{"id":"13304","subject":"[PATCH] git-daemon: fix for rotating logs","startedAt":"2008-04-28T14:24:07Z","lastAt":"2008-05-11T18:03:42Z","messageCount":23,"participants":["Johannes Schindelin","Junio C Hamano","Miklos Vajna","Mike Hommey","Stephen R. van den Berg","Andreas Ericsson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"75382","messageId":"alpine.DEB.1.00.0804281523040.5399@eeepc-johanness","threadId":"13304","inReplyTo":null,"subject":"[PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-28T14:24:07Z","receivedAt":"2008-04-28T14:24:07Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWith rotating logs, there is a problem when the syslog is opened only once \n(in the beginning).  So open the log everytime we write something, and \nclose it directly after writing.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n daemon.c |   11 +++++++----\n 1 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/daemon.c b/daemon.c\nindex 2b4a6f1..a887c72 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -90,7 +90,9 @@ static void logreport(int priority, const char *err, va_list params)\n \tmsglen = vsnprintf(buf + buflen, maxlen, err, params);\n \n \tif (log_syslog) {\n+\t\topenlog(\"git-daemon\", 0, LOG_DAEMON);\n \t\tsyslog(priority, \"%s\", buf);\n+\t\tcloselog();\n \t\treturn;\n \t}\n \n@@ -767,8 +769,11 @@ static void child_handler(int signo)\n \t\t\t\tconst char *dead = \"\";\n \t\t\t\tif (!WIFEXITED(status) || WEXITSTATUS(status) > 0)\n \t\t\t\t\tdead = \" (with error)\";\n-\t\t\t\tif (log_syslog)\n+\t\t\t\tif (log_syslog) {\n+\t\t\t\t\topenlog(\"git-daemon\", 0, LOG_DAEMON);\n \t\t\t\t\tsyslog(LOG_INFO, \"[%d] Disconnected%s\", pid, dead);\n+\t\t\t\t\tcloselog();\n+\t\t\t\t}\n \t\t\t\telse\n \t\t\t\t\tfprintf(stderr, \"[%d] Disconnected%s\\n\", pid, dead);\n \t\t\t}\n@@ -1149,10 +1154,8 @@ int main(int argc, char **argv)\n \t\tusage(daemon_usage);\n \t}\n \n-\tif (log_syslog) {\n-\t\topenlog(\"git-daemon\", 0, LOG_DAEMON);\n+\tif (log_syslog)\n \t\tset_die_routine(daemon_die);\n-\t}\n \n \tif (inetd_mode && (group_name || user_name))\n \t\tdie(\"--user and --group are incompatible with --inetd\");\n-- \n1.5.4.4.GIT\n"},{"id":"75396","messageId":"7vtzhmaqpd.fsf@gitster.siamese.dyndns.org","threadId":"13304","inReplyTo":"alpine.DEB.1.00.0804281523040.5399@eeepc-johanness","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-28T16:29:02Z","receivedAt":"2008-04-28T16:29:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> With rotating logs, there is a problem when the syslog is opened only once \n> (in the beginning).  So open the log everytime we write something, and \n> close it directly after writing.\n\nGaah, this is ugly.\n\nIs this something all the daemons need to deal with?\n\n> diff --git a/daemon.c b/daemon.c\n> index 2b4a6f1..a887c72 100644\n> --- a/daemon.c\n> +++ b/daemon.c\n> @@ -90,7 +90,9 @@ static void logreport(int priority, const char *err, va_list params)\n>  \tmsglen = vsnprintf(buf + buflen, maxlen, err, params);\n>  \n>  \tif (log_syslog) {\n> +\t\topenlog(\"git-daemon\", 0, LOG_DAEMON);\n>  \t\tsyslog(priority, \"%s\", buf);\n> +\t\tcloselog();\n>  \t\treturn;\n>  \t}\n"},{"id":"75418","messageId":"alpine.DEB.1.00.0804281908290.19187@eeepc-johanness","threadId":"13304","inReplyTo":"7vtzhmaqpd.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-28T18:08:50Z","receivedAt":"2008-04-28T18:08:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 28 Apr 2008, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > With rotating logs, there is a problem when the syslog is opened only \n> > once (in the beginning).  So open the log everytime we write \n> > something, and close it directly after writing.\n> \n> Gaah, this is ugly.\n> \n> Is this something all the daemons need to deal with?\n\nI have no idea, but it seems to fix a real issue.\n\nCiao,\nDscho\n"},{"id":"75420","messageId":"20080428182114.GF26880@genesis.frugalware.org","threadId":"13304","inReplyTo":"alpine.DEB.1.00.0804281908290.19187@eeepc-johanness","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-04-28T18:21:14Z","receivedAt":"2008-04-28T18:21:14Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > With rotating logs, there is a problem when the syslog is opened only \n> > > once (in the beginning).  So open the log everytime we write \n> > > something, and close it directly after writing.\n> > \n> > Gaah, this is ugly.\n> > \n> > Is this something all the daemons need to deal with?\n> \n> I have no idea, but it seems to fix a real issue.\n\nlogrotate supports sending a signal (typically SIGHUP) to the process\nafter it rotated the log. Couldn't we just re-open the log on SIGHUP?\n"},{"id":"75421","messageId":"20080428182917.GA4794@glandium.org","threadId":"13304","inReplyTo":"20080428182114.GF26880@genesis.frugalware.org","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2008-04-28T18:29:17Z","receivedAt":"2008-04-28T18:29:17Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:\n> On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > > With rotating logs, there is a problem when the syslog is opened only \n> > > > once (in the beginning).  So open the log everytime we write \n> > > > something, and close it directly after writing.\n> > > \n> > > Gaah, this is ugly.\n> > > \n> > > Is this something all the daemons need to deal with?\n> > \n> > I have no idea, but it seems to fix a real issue.\n> \n> logrotate supports sending a signal (typically SIGHUP) to the process\n> after it rotated the log. Couldn't we just re-open the log on SIGHUP?\n\nIsn't the problem that git-daemon loses its connection to the syslog\ndaemon when logrotate sighups syslog?\n\nMike\n"},{"id":"75422","messageId":"alpine.DEB.1.00.0804281937240.19187@eeepc-johanness","threadId":"13304","inReplyTo":"20080428182917.GA4794@glandium.org","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-28T18:37:54Z","receivedAt":"2008-04-28T18:37:54Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 28 Apr 2008, Mike Hommey wrote:\n\n> On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:\n> > On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > > > With rotating logs, there is a problem when the syslog is opened \n> > > > > only once (in the beginning).  So open the log everytime we \n> > > > > write something, and close it directly after writing.\n> > > > \n> > > > Gaah, this is ugly.\n> > > > \n> > > > Is this something all the daemons need to deal with?\n> > > \n> > > I have no idea, but it seems to fix a real issue.\n> > \n> > logrotate supports sending a signal (typically SIGHUP) to the process \n> > after it rotated the log. Couldn't we just re-open the log on SIGHUP?\n> \n> Isn't the problem that git-daemon loses its connection to the syslog \n> daemon when logrotate sighups syslog?\n\nI have no idea, but other programs must have the same problem.  I should \nhave shown some diligence and researched that.  Will do so now.\n\nCiao,\nDscho\n"},{"id":"75430","messageId":"20080428190047.GG26880@genesis.frugalware.org","threadId":"13304","inReplyTo":"alpine.DEB.1.00.0804281937240.19187@eeepc-johanness","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-04-28T19:00:47Z","receivedAt":"2008-04-28T19:00:47Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Mon, Apr 28, 2008 at 07:37:54PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > Isn't the problem that git-daemon loses its connection to the syslog \n> > daemon when logrotate sighups syslog?\n\nRight, but logrotate could send SIGHUP to git-daemon as well.\n\n> I have no idea, but other programs must have the same problem.  I should \n> have shown some diligence and researched that.  Will do so now.\n\nI don't say that just one example justifies me, but here is an example:\nicald (google://openlog+sighup 2nd result) does this.\n"},{"id":"75436","messageId":"alpine.DEB.1.00.0804282014130.19187@eeepc-johanness","threadId":"13304","inReplyTo":"20080428190047.GG26880@genesis.frugalware.org","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-28T19:24:47Z","receivedAt":"2008-04-28T19:24:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 28 Apr 2008, Miklos Vajna wrote:\n\n> On Mon, Apr 28, 2008 at 07:37:54PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > Isn't the problem that git-daemon loses its connection to the syslog \n> > > daemon when logrotate sighups syslog?\n> \n> Right, but logrotate could send SIGHUP to git-daemon as well.\n\nProbably.  But I do not understand how git-daemon just hangs when trying \nto close() something from within syslog().  Maybe my analysis is \ncompletely wrong, and I should do something completely different.\n\nCiao,\nDscho\n"},{"id":"75437","messageId":"20080428192837.GB21950@cuci.nl","threadId":"13304","inReplyTo":"20080428190047.GG26880@genesis.frugalware.org","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Stephen R. van den Berg","fromEmail":"srb@cuci.nl","sentAt":"2008-04-28T19:28:37Z","receivedAt":"2008-04-28T19:28:37Z","isPatch":true,"sender":{"key":"srb@cuci.nl","avatar":"https://gravatar.com/avatar/f75389059e827634d38e9df2a9b6ecbd50028b5a454442efa1c7205b7ff29c6a?d=mp&s=160"},"body":"Miklos Vajna wrote:\n>Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>> > Isn't the problem that git-daemon loses its connection to the syslog \n>> > daemon when logrotate sighups syslog?\n\nNo.\n\n>Right, but logrotate could send SIGHUP to git-daemon as well.\n\nIt could, but that's the reason one uses the openlog(3) interface to\nsyslog, to centralise logfilemanagement and *not* having to deal with\nthe intricacies of logfile rotation and the like.  So it doesn't need\nto.  When you need logfile rotation, you're better off with using\nopenlog(3), and doing that the proper way means *NOT* closing and\nreopening that everytime.\n\n>> I have no idea, but other programs must have the same problem.  I should \n\nThey don't.  Your patch fixes the wrong problem.  Please don't fix\nsomething that wasn't broken in the first place.\n\n>> have shown some diligence and researched that.  Will do so now.\n\n>I don't say that just one example justifies me, but here is an example:\n>icald (google://openlog+sighup 2nd result) does this.\n\nN.B. I've never had to close and reopen the openlog(3) syslog interface\nin any of the daemons I've written.\nThe example you refer to of icald is where it directly writes to a\nlogfile, which is *not* what this patch was about, so please do not use\nit as justification.\n-- \nSincerely,                                                          srb@cuci.nl\n           Stephen R. van den Berg.\n"},{"id":"75444","messageId":"alpine.DEB.1.00.0804282052050.19187@eeepc-johanness","threadId":"13304","inReplyTo":"20080428192837.GB21950@cuci.nl","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-28T19:53:44Z","receivedAt":"2008-04-28T19:53:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nsince you seem to be very new to this list: we really appreciate a \nReply-to-all here.\n\nOn Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n\n> >> I have no idea, but other programs must have the same problem.  I \n> >> should\n> \n> They don't.  Your patch fixes the wrong problem.  Please don't fix \n> something that wasn't broken in the first place.\n\nSo do you have any ideas what is happening there?  It seems that after \nlogrotate does its thing, syslog() is stuck in the close() call.\n\nAny constructive help is very much appreciated.\n\nCiao,\nDscho\n"},{"id":"75450","messageId":"20080428204323.GA22815@cuci.nl","threadId":"13304","inReplyTo":"alpine.DEB.1.00.0804282052050.19187@eeepc-johanness","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Stephen R. van den Berg","fromEmail":"srb@cuci.nl","sentAt":"2008-04-28T20:43:23Z","receivedAt":"2008-04-28T20:43:23Z","isPatch":true,"sender":{"key":"srb@cuci.nl","avatar":"https://gravatar.com/avatar/f75389059e827634d38e9df2a9b6ecbd50028b5a454442efa1c7205b7ff29c6a?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n>since you seem to be very new to this list: we really appreciate a \n>Reply-to-all here.\n\nI see.  I normally consider that bad form (maybe my age shows ;-);\nbut if people insist here, no problem.\n\n>On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n\n>> >> I have no idea, but other programs must have the same problem.  I \n>> >> should\n\n>So do you have any ideas what is happening there?  It seems that after \n>logrotate does its thing, syslog() is stuck in the close() call.\n\nErm, just so I understand the problem:\n- git-daemon is configured to use syslog(3) to log\n- git-daemon uses openlog(3)\n- git-daemon logs happily for a while\n- rotatelog rotates logfiles in /var/log and communicates with syslogd\n  to make sure syslogd starts new logfiles in /var/log\n- And then git-daemon hangs on which system/library call?\n-- \nSincerely,                                                          srb@cuci.nl\n           Stephen R. van den Berg.\n"},{"id":"75451","messageId":"alpine.DEB.1.00.0804282153290.19187@eeepc-johanness","threadId":"13304","inReplyTo":"20080428204323.GA22815@cuci.nl","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-28T20:53:53Z","receivedAt":"2008-04-28T20:53:53Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n\n> Johannes Schindelin wrote:\n> \n> >On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n> \n> >> >> I have no idea, but other programs must have the same problem.  I \n> >> >> should\n> \n> >So do you have any ideas what is happening there?  It seems that after \n> >logrotate does its thing, syslog() is stuck in the close() call.\n> \n> Erm, just so I understand the problem:\n> - git-daemon is configured to use syslog(3) to log\n> - git-daemon uses openlog(3)\n> - git-daemon logs happily for a while\n> - rotatelog rotates logfiles in /var/log and communicates with syslogd\n>   to make sure syslogd starts new logfiles in /var/log\n> - And then git-daemon hangs on which system/library call?\n\nIt seems that this happens, yes.\n\nCiao,\nDscho\n"},{"id":"75453","messageId":"20080428210003.GB22815@cuci.nl","threadId":"13304","inReplyTo":"alpine.DEB.1.00.0804282153290.19187@eeepc-johanness","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Stephen R. van den Berg","fromEmail":"srb@cuci.nl","sentAt":"2008-04-28T21:00:03Z","receivedAt":"2008-04-28T21:00:03Z","isPatch":true,"sender":{"key":"srb@cuci.nl","avatar":"https://gravatar.com/avatar/f75389059e827634d38e9df2a9b6ecbd50028b5a454442efa1c7205b7ff29c6a?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n>On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n>> - git-daemon logs happily for a while\n>> - rotatelog rotates logfiles in /var/log and communicates with syslogd\n>>   to make sure syslogd starts new logfiles in /var/log\n>> - And then git-daemon hangs on which system/library call?\n\n>It seems that this happens, yes.\n\nCould you hang an strace off of git-daemon and check what system call it\nhangs on at that point in time?\n-- \nSincerely,                                                          srb@cuci.nl\n           Stephen R. van den Berg.\n"},{"id":"75457","messageId":"alpine.DEB.1.00.0804282209230.19187@eeepc-johanness","threadId":"13304","inReplyTo":"20080428210003.GB22815@cuci.nl","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-28T21:09:54Z","receivedAt":"2008-04-28T21:09:54Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n\n> Johannes Schindelin wrote:\n> >On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n> >> - git-daemon logs happily for a while\n> >> - rotatelog rotates logfiles in /var/log and communicates with syslogd\n> >>   to make sure syslogd starts new logfiles in /var/log\n> >> - And then git-daemon hangs on which system/library call?\n> \n> >It seems that this happens, yes.\n> \n> Could you hang an strace off of git-daemon and check what system call it\n> hangs on at that point in time?\n\nI can do better than that.  I attached to the process, and like I said, it \nhung in close().\n\nCiao,\nDscho\n"},{"id":"75458","messageId":"20080428211328.GC22815@cuci.nl","threadId":"13304","inReplyTo":"alpine.DEB.1.00.0804282209230.19187@eeepc-johanness","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Stephen R. van den Berg","fromEmail":"srb@cuci.nl","sentAt":"2008-04-28T21:13:28Z","receivedAt":"2008-04-28T21:13:28Z","isPatch":true,"sender":{"key":"srb@cuci.nl","avatar":"https://gravatar.com/avatar/f75389059e827634d38e9df2a9b6ecbd50028b5a454442efa1c7205b7ff29c6a?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n>On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n>> Johannes Schindelin wrote:\n>> >On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n>> >> - rotatelog rotates logfiles in /var/log and communicates with syslogd\n>> >>   to make sure syslogd starts new logfiles in /var/log\n>> >> - And then git-daemon hangs on which system/library call?\n\n>I can do better than that.  I attached to the process, and like I said, it \n>hung in close().\n\nOn which descriptor?  (I.e. what does the descriptor point to?)\n-- \nSincerely,                                                          srb@cuci.nl\n           Stephen R. van den Berg.\n"},{"id":"75461","messageId":"alpine.DEB.1.00.0804282222150.19187@eeepc-johanness","threadId":"13304","inReplyTo":"20080428211328.GC22815@cuci.nl","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-28T21:23:07Z","receivedAt":"2008-04-28T21:23:07Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n\n> Johannes Schindelin wrote:\n> >On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n> >> Johannes Schindelin wrote:\n> >> >On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n> >> >> - rotatelog rotates logfiles in /var/log and communicates with syslogd\n> >> >>   to make sure syslogd starts new logfiles in /var/log\n> >> >> - And then git-daemon hangs on which system/library call?\n> \n> >I can do better than that.  I attached to the process, and like I said, it \n> >hung in close().\n> \n> On which descriptor?  (I.e. what does the descriptor point to?)\n\nSorry, that I don't remember, but I strongly suspect the syslog \ndescriptor, since the backtrace showed \"syslog()\" a few levels up of \nclose().\n\nCiao,\nDscho\n"},{"id":"75475","messageId":"20080428231628.GD22815@cuci.nl","threadId":"13304","inReplyTo":"alpine.DEB.1.00.0804282222150.19187@eeepc-johanness","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Stephen R. van den Berg","fromEmail":"srb@cuci.nl","sentAt":"2008-04-28T23:16:28Z","receivedAt":"2008-04-28T23:16:28Z","isPatch":true,"sender":{"key":"srb@cuci.nl","avatar":"https://gravatar.com/avatar/f75389059e827634d38e9df2a9b6ecbd50028b5a454442efa1c7205b7ff29c6a?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n>On Mon, 28 Apr 2008, Stephen R. van den Berg wrote:\n>> >I can do better than that.  I attached to the process, and like I said, it \n>> >hung in close().\n\n>> On which descriptor?  (I.e. what does the descriptor point to?)\n\n>Sorry, that I don't remember, but I strongly suspect the syslog \n>descriptor, since the backtrace showed \"syslog()\" a few levels up of \n>close().\n\nAFAICT, sending SIGHUP to syslogd doesn't cause the /dev/log pipe to be\nclosed, therefore there shouldn't be any closing of that /dev/log pipe.\nSo if you can reproduce it, please report which filedescriptor it is\ntrying to close.\n-- \nSincerely,                                                          srb@cuci.nl\n           Stephen R. van den Berg.\n"},{"id":"75493","messageId":"4816BD77.1060709@op5.se","threadId":"13304","inReplyTo":"20080428182917.GA4794@glandium.org","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-04-29T06:17:27Z","receivedAt":"2008-04-29T06:17:27Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Mike Hommey wrote:\n> On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:\n>> On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>>>>> With rotating logs, there is a problem when the syslog is opened only \n>>>>> once (in the beginning).  So open the log everytime we write \n>>>>> something, and close it directly after writing.\n>>>> Gaah, this is ugly.\n>>>>\n>>>> Is this something all the daemons need to deal with?\n>>> I have no idea, but it seems to fix a real issue.\n>> logrotate supports sending a signal (typically SIGHUP) to the process\n>> after it rotated the log. Couldn't we just re-open the log on SIGHUP?\n> \n> Isn't the problem that git-daemon loses its connection to the syslog\n> daemon when logrotate sighups syslog?\n> \n\nIt really shouldn't. The connection to the syslog daemon is just a\nunix socket (/dev/log) which is used to send whatever passes for\nUDP packets on unix domain sockets. Since the socket isn't re-created\nby syslogd (well, a sane syslogd anyways), but rather just open()'ed\nfor reading, no program should ever need to reconnect.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"75518","messageId":"alpine.DEB.1.00.0804291153230.27457@eeepc-johanness","threadId":"13304","inReplyTo":"4816BD77.1060709@op5.se","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-29T10:54:27Z","receivedAt":"2008-04-29T10:54:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 29 Apr 2008, Andreas Ericsson wrote:\n\n> Mike Hommey wrote:\n> > On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:\n> > > On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin\n> > > <Johannes.Schindelin@gmx.de> wrote:\n> > > > > > With rotating logs, there is a problem when the syslog is opened\n> > > > > > only once (in the beginning).  So open the log everytime we write\n> > > > > > something, and close it directly after writing.\n> > > > > Gaah, this is ugly.\n> > > > >\n> > > > > Is this something all the daemons need to deal with?\n> > > > I have no idea, but it seems to fix a real issue.\n> > > logrotate supports sending a signal (typically SIGHUP) to the process\n> > > after it rotated the log. Couldn't we just re-open the log on SIGHUP?\n> > \n> > Isn't the problem that git-daemon loses its connection to the syslog\n> > daemon when logrotate sighups syslog?\n> > \n> \n> It really shouldn't. The connection to the syslog daemon is just a\n> unix socket (/dev/log) which is used to send whatever passes for\n> UDP packets on unix domain sockets. Since the socket isn't re-created\n> by syslogd (well, a sane syslogd anyways), but rather just open()'ed\n> for reading, no program should ever need to reconnect.\n\nWhat can I say?  The problem just went away with my workaround.  Is it \npossible that I have to catch SIGHUP, and closelog() && openlog()?  But \nwhy do other daemons seem to not have that problem at all?\n\nCiao,\nDscho\n"},{"id":"75519","messageId":"4816FFEB.8050308@op5.se","threadId":"13304","inReplyTo":"alpine.DEB.1.00.0804291153230.27457@eeepc-johanness","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-04-29T11:00:59Z","receivedAt":"2008-04-29T11:00:59Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n> Hi,\n> \n> On Tue, 29 Apr 2008, Andreas Ericsson wrote:\n> \n>> Mike Hommey wrote:\n>>> On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:\n>>>> On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin\n>>>> <Johannes.Schindelin@gmx.de> wrote:\n>>>>>>> With rotating logs, there is a problem when the syslog is opened\n>>>>>>> only once (in the beginning).  So open the log everytime we write\n>>>>>>> something, and close it directly after writing.\n>>>>>> Gaah, this is ugly.\n>>>>>>\n>>>>>> Is this something all the daemons need to deal with?\n>>>>> I have no idea, but it seems to fix a real issue.\n>>>> logrotate supports sending a signal (typically SIGHUP) to the process\n>>>> after it rotated the log. Couldn't we just re-open the log on SIGHUP?\n>>> Isn't the problem that git-daemon loses its connection to the syslog\n>>> daemon when logrotate sighups syslog?\n>>>\n>> It really shouldn't. The connection to the syslog daemon is just a\n>> unix socket (/dev/log) which is used to send whatever passes for\n>> UDP packets on unix domain sockets. Since the socket isn't re-created\n>> by syslogd (well, a sane syslogd anyways), but rather just open()'ed\n>> for reading, no program should ever need to reconnect.\n> \n> What can I say?  The problem just went away with my workaround.  Is it \n> possible that I have to catch SIGHUP, and closelog() && openlog()?  But \n> why do other daemons seem to not have that problem at all?\n> \n\nOther daemons don't get SIGHUP'ed when logs are rotated. I think something\nelse is going on there.\n\nWhat syslogd are you using? Perhaps it insists on re-creating the socket.\nThat might cause the behaviour you're seeing, but then you should probably\nsee it in a ton of other daemons as well.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"75532","messageId":"alpine.DEB.1.00.0804291615000.27457@eeepc-johanness","threadId":"13304","inReplyTo":"4816FFEB.8050308@op5.se","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-29T15:16:03Z","receivedAt":"2008-04-29T15:16:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 29 Apr 2008, Andreas Ericsson wrote:\n\n> Johannes Schindelin wrote:\n> \n> > On Tue, 29 Apr 2008, Andreas Ericsson wrote:\n> > \n> > > Mike Hommey wrote:\n> > > > On Mon, Apr 28, 2008 at 08:21:14PM +0200, Miklos Vajna wrote:\n> > > > > On Mon, Apr 28, 2008 at 07:08:50PM +0100, Johannes Schindelin \n> > > > > <Johannes.Schindelin@gmx.de> wrote:\n> > > > > > > > With rotating logs, there is a problem when the syslog is \n> > > > > > > > opened only once (in the beginning).  So open the log \n> > > > > > > > everytime we write something, and close it directly after \n> > > > > > > > writing.\n> > > > > > > Gaah, this is ugly.\n> > > > > > >\n> > > > > > > Is this something all the daemons need to deal with?\n> > > > > > I have no idea, but it seems to fix a real issue.\n> > > > > logrotate supports sending a signal (typically SIGHUP) to the \n> > > > > process after it rotated the log. Couldn't we just re-open the \n> > > > > log on SIGHUP?\n> > > > Isn't the problem that git-daemon loses its connection to the \n> > > > syslog daemon when logrotate sighups syslog?\n> > > >\n> > > It really shouldn't. The connection to the syslog daemon is just a \n> > > unix socket (/dev/log) which is used to send whatever passes for UDP \n> > > packets on unix domain sockets. Since the socket isn't re-created by \n> > > syslogd (well, a sane syslogd anyways), but rather just open()'ed \n> > > for reading, no program should ever need to reconnect.\n> > \n> > What can I say?  The problem just went away with my workaround.  Is it \n> > possible that I have to catch SIGHUP, and closelog() && openlog()?  \n> > But why do other daemons seem to not have that problem at all?\n> > \n> \n> Other daemons don't get SIGHUP'ed when logs are rotated. I think \n> something else is going on there.\n> \n> What syslogd are you using? Perhaps it insists on re-creating the \n> socket. That might cause the behaviour you're seeing, but then you \n> should probably see it in a ton of other daemons as well.\n\nThis is sysklogd from Ubuntu, compiled for amd64.  The timestamp on \n/dev/log is older than a month.\n\nThanks,\nDscho\n"},{"id":"75555","messageId":"20080429175828.GA32301@cuci.nl","threadId":"13304","inReplyTo":"alpine.DEB.1.00.0804291615000.27457@eeepc-johanness","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Stephen R. van den Berg","fromEmail":"srb@cuci.nl","sentAt":"2008-04-29T17:58:28Z","receivedAt":"2008-04-29T17:58:28Z","isPatch":true,"sender":{"key":"srb@cuci.nl","avatar":"https://gravatar.com/avatar/f75389059e827634d38e9df2a9b6ecbd50028b5a454442efa1c7205b7ff29c6a?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n>On Tue, 29 Apr 2008, Andreas Ericsson wrote:\n>> What syslogd are you using? Perhaps it insists on re-creating the \n>> socket. That might cause the behaviour you're seeing, but then you \n>> should probably see it in a ton of other daemons as well.\n\nRecreating the socket should not cause this to happen either, because\nthe git-daemon will still hold on to the old inode (even after the file\nhas been removed).\n\n>This is sysklogd from Ubuntu, compiled for amd64.  The timestamp on \n>/dev/log is older than a month.\n\nI'd still recommend trying to reproduce the problem, then find out which\nfiledescriptor/file the close is hanging on.\n-- \nSincerely,                                                          srb@cuci.nl\n           Stephen R. van den Berg.\n"},{"id":"76648","messageId":"alpine.DEB.1.00.0805111901390.30431@racer","threadId":"13304","inReplyTo":"alpine.DEB.1.00.0804281523040.5399@eeepc-johanness","subject":"Re: [PATCH] git-daemon: fix for rotating logs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-05-11T18:03:42Z","receivedAt":"2008-05-11T18:03:42Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 28 Apr 2008, Johannes Schindelin wrote:\n\n> With rotating logs, there is a problem when the syslog is opened only \n> once (in the beginning).  So open the log everytime we write something, \n> and close it directly after writing.\n\nActually, the culprit were _not_ rotating logs.  At least not really.  \nsyslog() is not supposed to be called from a signal handler.  In \ngit-daemon, it is, from child_handler(), but only when called with \n--verbose (and --syslog, or --detach).  Bummer.\n\nSorry for my wrong analysis,\nDscho\n"}]}