[vhffs-dev] [2173] fixed web and repository stats abortion if we cannot run the postrotate command line

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2173
Author:   gradator
Date:     2012-05-04 22:15:40 +0200 (Fri, 04 May 2012)
Log Message:
-----------
fixed web and repository stats abortion if we cannot run the postrotate command line

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
    trunk/vhffs-api/src/Vhffs/Robots/Web.pm

Modified: trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Repository.pm	2012-05-03 21:05:31 UTC (rev 2172)
+++ trunk/vhffs-api/src/Vhffs/Robots/Repository.pm	2012-05-04 20:15:40 UTC (rev 2173)
@@ -227,6 +227,8 @@
 
 	# Run the post rotate command
 	if( $repoconf->{'log_postrotate'} ) {
+		my $ret;
+
 		my $childpid = open( my $output, '-|', split( /\s+/, $repoconf->{'log_postrotate'} ) );
 		if($childpid) {
 			# read process output and discard
@@ -241,11 +243,13 @@
 			# -- exit value is 0 if the process success
 			# -- core dump bit is 0 if no core dump were written to disk
 			# ---- so, $? contains 0 if everything went fine
-			if( $? ) {
-				print 'ERROR: failed to run the postrotate command line, aborting: '.$repoconf->{'log_postrotate'}."\n";
-				return;
-			}
+			$ret = $?;
 		}
+
+		unless( defined $ret and $ret == 0 ) {
+			print 'ERROR: failed to run the postrotate command line, aborting: '.$repoconf->{'log_postrotate'}."\n";
+			return;
+		}
 	}
 
 	# Deleting previous logs

Modified: trunk/vhffs-api/src/Vhffs/Robots/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Web.pm	2012-05-03 21:05:31 UTC (rev 2172)
+++ trunk/vhffs-api/src/Vhffs/Robots/Web.pm	2012-05-04 20:15:40 UTC (rev 2173)
@@ -199,6 +199,8 @@
 
 	# Run the post rotate command
 	if( $webconf->{'log_postrotate'} ) {
+		my $ret;
+
 		my $childpid = open( my $output, '-|', split( /\s+/, $webconf->{'log_postrotate'} ) );
 		if($childpid) {
 			# read process output and discard
@@ -213,11 +215,13 @@
 			# -- exit value is 0 if the process success
 			# -- core dump bit is 0 if no core dump were written to disk
 			# ---- so, $? contains 0 if everything went fine
-			if( $? ) {
-				print 'ERROR: failed to run the postrotate command line, aborting: '.$webconf->{'log_postrotate'}."\n";
-				return;
-			}
+			$ret = $?;
 		}
+
+		unless( defined $ret and $ret == 0 ) {
+			print 'ERROR: failed to run the postrotate command line, aborting: '.$webconf->{'log_postrotate'}."\n";
+			return;
+		}
 	}
 
 	# Deleting previous logs


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/