Browse Source

Ticket 47446 - logconv.pl memory continually grows

Bug Description:  Running logconv.pl without any special options
                  continually consumes more memory.

Fix Description:  The last fix introduced the use of regex matches which
                  caused the value of $1 to become undefined.  When using
                  all of the logconv cmd line switches, many undefined
                  variable warnings were printed.  This fix saves the value
                  of $1 in a local variable so that it it not undefined by
                  the use of subsequent regex matches.

https://fedorahosted.org/389/ticket/47446

Reviewed by: mreynolds (Thanks!)
Rich Megginson 11 years ago
parent
commit
c4f396db24
1 changed files with 11 additions and 6 deletions
  1. 11 6
      ldap/admin/src/logconv.pl

+ 11 - 6
ldap/admin/src/logconv.pl

@@ -1825,10 +1825,11 @@ sub parseLineNormal
 		$srchCount++;
 		if($reportStats){ inc_stats('srch',$s_stats,$m_stats); }
 		if ($_ =~ / attrs=\"(.*)\"/i){
+			my $attrlist = $1;
 			$anyAttrs++;
 			if ($usage =~ /r/i || $verb eq "yes"){
 				my $attr = $hashes->{attr};
-				map { $attr->{$_}++ } split /\s/, $1;
+				map { $attr->{$_}++ } split /\s/, $attrlist;
 			}
 		}
 		if (/ attrs=ALL/){
@@ -2271,8 +2272,9 @@ sub parseLineNormal
 		}
 	}
 	if ($_ =~ /err= *([0-9]+)/i){
-		if ($usage =~ /e/i || $verb eq "yes"){ $errorCode[$1]++; }
-		if ($1 ne "0"){ $errorCount++;}
+		my $errcode = $1;
+		if ($usage =~ /e/i || $verb eq "yes"){ $errorCode[$errcode]++; }
+		if ($errcode ne "0"){ $errorCount++;}
 		else { $successCount++;}
 	}
 	if ($_ =~ /etime= *([0-9.]+)/ ) { 
@@ -2282,8 +2284,9 @@ sub parseLineNormal
 	}
 	if ($_ =~ / tag=101 / || $_ =~ / tag=111 / || $_ =~ / tag=100 / || $_ =~ / tag=115 /){
 		if ($_ =~ / nentries= *([0-9]+)/i ){ 
+			my $nents = $1;
 			if ($usage =~ /n/i || $verb eq "yes"){ 
-				$hashes->{nentries}->{$1}++; 
+				$hashes->{nentries}->{$nents}++; 
 			}
 		}
 	}
@@ -2292,10 +2295,12 @@ sub parseLineNormal
 	}
 	if (m/ EXT oid=/){
 		$extopCount++;
+		my $oid;
 		if ($_ =~ /oid=\" *([0-9\.]+)/i ){ 
-			if ($usage =~ /x/i || $verb eq "yes"){$hashes->{oid}->{$1}++; }
+			$oid = $1;
+			if ($usage =~ /x/i || $verb eq "yes"){$hashes->{oid}->{$oid}++; }
 		}
-		if ($1 && $1 eq $startTLSoid){$startTLSCount++;}
+		if ($oid && $oid eq $startTLSoid){$startTLSCount++;}
 		if ($verb eq "yes"){
 			if ($_ =~ /conn= *([0-9A-Z]+) +op= *([0-9\-]+)/i){ $hashes->{ext_conn_op}->{"$serverRestartCount,$1,$2"}++;}
 		}