INN commit: branches (6 files)

INN Commit rra at isc.org
Mon Jun 3 18:12:39 UTC 2013


    Date: Monday, June 3, 2013 @ 11:12:39
  Author: iulius
Revision: 9479

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:
  branches/2.5/	(properties)
  branches/2.5/doc/pod/innfeed.conf.pod
  branches/2.5/doc/pod/innfeed.pod
  branches/2.5/doc/pod/news.pod
  branches/2.5/innfeed/main.c
  branches/2.5/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(-)


Property changes on: branches/2.5
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:9476-9477
   + 

Modified: 2.5/doc/pod/innfeed.conf.pod
===================================================================
--- 2.5/doc/pod/innfeed.conf.pod	2013-05-24 16:28:27 UTC (rev 9478)
+++ 2.5/doc/pod/innfeed.conf.pod	2013-06-03 18:12:39 UTC (rev 9479)
@@ -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: 2.5/doc/pod/innfeed.pod
===================================================================
--- 2.5/doc/pod/innfeed.pod	2013-05-24 16:28:27 UTC (rev 9478)
+++ 2.5/doc/pod/innfeed.pod	2013-06-03 18:12:39 UTC (rev 9479)
@@ -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: 2.5/doc/pod/news.pod
===================================================================
--- 2.5/doc/pod/news.pod	2013-05-24 16:28:27 UTC (rev 9478)
+++ 2.5/doc/pod/news.pod	2013-06-03 18:12:39 UTC (rev 9479)
@@ -12,13 +12,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: 2.5/innfeed/main.c
===================================================================
--- 2.5/innfeed/main.c	2013-05-24 16:28:27 UTC (rev 9478)
+++ 2.5/innfeed/main.c	2013-06-03 18:12:39 UTC (rev 9479)
@@ -572,6 +572,9 @@
     }
 
   configHosts (talkToSelf) ;
+
+  notice ("ME reloading log file %s", logFile) ;
+  openLogFile() ;
 }
 
 static void sigemt (int sig UNUSED)

Modified: 2.5/scripts/scanlogs.in
===================================================================
--- 2.5/scripts/scanlogs.in	2013-05-24 16:28:27 UTC (rev 9478)
+++ 2.5/scripts/scanlogs.in	2013-06-03 18:12:39 UTC (rev 9479)
@@ -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