INN commit: trunk (5 files)

INN Commit rra at isc.org
Sat Jun 8 14:49:37 UTC 2013


    Date: Saturday, June 8, 2013 @ 07:49:36
  Author: iulius
Revision: 9484

innfeed, scanlogs:  reopen log files on sighup

The recent patch [9464] to flush exploder and process channels in innd,
and to send 'ctlinnd flushlogs' again after log rotation solved the
problem of controlchan or ninpaths holding open an already deleted
errlog file.  However this does not yet solve the original issue with
innfeed.log when innfeed is run as a standalone daemon via a funnel-file.

This patch implements the changes suggested by Julien Elie in January
2013, to add an openLogFile() call to the sighup handler.  The sigusr1
handler is not available, as it is already used to increase / decrease
the debugging level along with sigusr2.  Also, reopening the log after
re-reading the configuration might be a good idea anyway, as the log
file location may have been changed.

Additionally, call sighup on the innfeed pid in scanlogs, and document
the changes briefly in innfeed(8) / innfeed.conf(5).

Thanks to Florian Schlichting for the patch.

Modified:
  trunk/doc/pod/innfeed.conf.pod
  trunk/doc/pod/innfeed.pod
  trunk/doc/pod/news.pod
  trunk/innfeed/main.c
  trunk/scripts/scanlogs.in

--------------------------+
 doc/pod/innfeed.conf.pod |    2 ++
 doc/pod/innfeed.pod      |    4 ++--
 doc/pod/news.pod         |   15 +++++++++++----
 innfeed/main.c           |    3 +++
 scripts/scanlogs.in      |   24 ++++++++++++++----------
 5 files changed, 32 insertions(+), 16 deletions(-)

Modified: doc/pod/innfeed.conf.pod
===================================================================
--- doc/pod/innfeed.conf.pod	2013-06-06 20:10:20 UTC (rev 9483)
+++ doc/pod/innfeed.conf.pod	2013-06-08 14:49:36 UTC (rev 9484)
@@ -693,6 +693,8 @@
 
 Any new peers are added and any missing peers have their connections closed.
 
+The log file is also reopened.
+
 =head1 EXAMPLE
 
 For a comprehensive example, see the sample F<innfeed.conf> distributed

Modified: doc/pod/innfeed.pod
===================================================================
--- doc/pod/innfeed.pod	2013-06-06 20:10:20 UTC (rev 9483)
+++ doc/pod/innfeed.pod	2013-06-08 14:49:36 UTC (rev 9484)
@@ -141,8 +141,8 @@
 B<innfeed> with catch SIGINT and will write a large debugging snapshot of
 the state of the running system.
 
-B<innfeed> will catch SIGHUP and will reload the config file.
-See innfeed.conf(5) for more details.
+B<innfeed> will catch SIGHUP and will reload both the config and the
+log files.  See innfeed.conf(5) for more details.
 
 B<innfeed> will catch SIGCHLD and will close and reopen all backlog files.
 

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2013-06-06 20:10:20 UTC (rev 9483)
+++ doc/pod/news.pod	2013-06-08 14:49:36 UTC (rev 9484)
@@ -138,13 +138,20 @@
 =item *
 
 When using funnel feeds, B<innfeed> log files were open forever, which
-resulted in empty log files, once rotated by B<scanlogs>.  Exploder and
-process channels are now reopened when C<ctlinnd flushlogs> is used,
-which is in particular the command invoked by B<scanlogs> to rotate
-log files.
+resulted in empty log files, once rotated by B<scanlogs>.  B<innfeed>
+now reopens its log files upon receiving a HUP signal; this signal
+is in particular sent by B<scanlogs> during log rotation.  Thanks to
+Florian Schlichting for the patch.
 
 =item *
 
+Exploder and process channels are now reopened when C<ctlinnd flushlogs>
+is used.  Otherwise, they could hold open an already deleted F<errlog>
+file.  The issue affected in particular B<controlchan> or B<ninpaths>,
+running as such channels.
+
+=item *
+
 Fixed the occurrence of an unexpected C<cant select> error generated by
 B<innd>.  Thanks to Paul Tomblin for having caught that long-standing
 issue.

Modified: innfeed/main.c
===================================================================
--- innfeed/main.c	2013-06-06 20:10:20 UTC (rev 9483)
+++ innfeed/main.c	2013-06-08 14:49:36 UTC (rev 9484)
@@ -572,6 +572,9 @@
     }
 
   configHosts (talkToSelf) ;
+
+  notice ("ME reloading log file %s", logFile) ;
+  openLogFile() ;
 }
 
 static void sigemt (int sig UNUSED)

Modified: scripts/scanlogs.in
===================================================================
--- scripts/scanlogs.in	2013-06-06 20:10:20 UTC (rev 9483)
+++ scripts/scanlogs.in	2013-06-08 14:49:36 UTC (rev 9484)
@@ -25,6 +25,7 @@
 INNFEEDCONF=${PATHETC}/innfeed.conf
 if [ -f "${INNFEEDCONF}" ]; then
     INNFEEDLOG=`${AWK} '{gsub(/:|#/, " & ")} {if ($1 == "log-file" && $2 == ":") print $3}' ${INNFEEDCONF}`
+    INNFEEDPIDFILE=`${AWK} '{gsub(/:|#/, " & ")} {if ($1 == "pid-file" && $2 == ":") print $3}' ${INNFEEDCONF}`
 fi
 INNFEED=
 for F in "${INNFEEDLOG}" ; do
@@ -112,8 +113,8 @@
     PAUSED=false
     ctlinnd -s pause "Flushing log and syslog files" 2>&1 && PAUSED=true
 
-    # First, flush log files to be sure everything has been recorded
-    # before rotating them.
+    ##  First, flush log files to be sure everything has been recorded
+    ##  before rotating them.
     OUTPUT=`ctlinnd flushlogs 2>&1`
     if [ "$OUTPUT" != "Ok" -a "$OUTPUT" != "In debug mode" ]; then
 	echo "$OUTPUT"
@@ -160,14 +161,17 @@
     ##  Tally control messages if we logged them.
     test -n "${CONTROL_DATA}" && cat ${CONTROL_DATA} | ${TALLY_CONTROL}
 
-    # Flush again log files so that freshly rotated new log files
-    # are properly taken into account.
-    OUTPUT=`ctlinnd flushlogs 2>&1`
-    if [ "$OUTPUT" != "Ok" -a "$OUTPUT" != "In debug mode" ]; then
-        echo "$OUTPUT"
-        echo 'Cannot flush logs.'
-        rm -f ${LOCK}
-        exit 1
+    ##  Find out the PID of innfeed now and not at the beginning of scanlogs
+    ##  because it is restarted when running ctlinnd flushlogs.
+    INNFEEDPID=
+    for F in "${INNFEEDPIDFILE}" ; do
+        test -f "${PATHRUN}/${F}" && INNFEEDPID=`cat "${PATHRUN}/${F}"`
+    done
+    test -z "${INNFEEDPID}" && test -f "${PATHRUN}/innfeed.pid" && INNFEEDPID=`cat "${PATHRUN}/innfeed.pid"`
+
+    ##  Send a HUP signal to innfeed so that it reopens its log files.
+    if [ ! -z ${INNFEEDPID} ]; then
+        kill -HUP ${INNFEEDPID} > /dev/null 2>&1
     fi
 
     ${PAUSED} && ctlinnd -s go "Flushing log and syslog files" 2>&1



More information about the inn-committers mailing list