[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[OSSTEST PATCH 05/60] history reporting (nfc): Make cache_write_entry into a top-level sub


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Date: Fri, 14 Aug 2020 18:21:10 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Delivery-date: Fri, 14 Aug 2020 17:22:29 +0000
  • Ironport-sdr: gGBUpPHDUEVc/bmQu3o7aloOTSEwnX+ETtRovKb0ZTBHJzZzwYL1Qmy7ht8vRXIHRBjFWIvx+c DEGKDM9B8g6IRsFsHl4y3u64j6OUh2xsfj+pJ4uc11DveaHaG6ziaoy6ejSfzHcY1XeYGSVYCY 4fRHCIkn335Rdxk6F6XBJUAbC+MWd9YyT0yg4ykiiA8zDvzRnLpLAi4X3VDILwrPrgxj5ERn2t 6WOzpaGoDMbjDcXF4bDWNdVQi3yf9xdDCSISjL7+C+7luuB/P1Ubo1jWVLrIgk6TSne/i2iGZr wAQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 sg-report-host-history | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/sg-report-host-history b/sg-report-host-history
index 83344a40..fe5b7cc2 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -112,6 +112,27 @@ sub cache_read_existing ($) {
     close H;
 }
 
+sub cache_write_entry ($$) {
+    my ($fh, $jr) = @_;
+    print $fh "<!-- osstest-report-reuseable";
+    my $whash = sub {
+       my ($h) = @_;
+       foreach my $k (sort keys %$h) {
+           next if $k =~ m/^\%/;
+           $_ = $h->{$k};
+           s{[^-+=/~:;_.,\w]}{ sprintf "%%%02x", ord $& }ge;
+           printf $fh " %s=%s", $k, $_;
+       }
+    };
+    $whash->($jr);
+    foreach my $hk (sort keys %$jr) {
+       next unless $hk =~ m/^\%/;
+       print $fh " $'";
+       $whash->($jr->{$hk});
+    }
+    print $fh " -->\n";
+}
+
 sub computeflightsrange () {
     if ($flightlimit) {
        my $minflightsq = db_prepare(<<END);
@@ -285,27 +306,6 @@ END
     print DEBUG "CACHE $hostname $cachehits / ".(scalar @rows)
        ." of ".(scalar %cache)."\n";
 
-    my $write_cache_entry = sub {
-       my ($jr) = @_;
-        print H "<!-- osstest-report-reuseable";
-       my $whash = sub {
-           my ($h) = @_;
-           foreach my $k (sort keys %$h) {
-               next if $k =~ m/^\%/;
-               $_ = $h->{$k};
-               s{[^-+=/~:;_.,\w]}{ sprintf "%%%02x", ord $& }ge;
-               printf H " %s=%s", $k, $_;
-           }
-       };
-       $whash->($jr);
-       foreach my $hk (sort keys %$jr) {
-           next unless $hk =~ m/^\%/;
-           print H " $'";
-           $whash->($jr->{$hk});
-       }
-       print H " -->\n";
-    };
-
     @rows = sort { $b->{finished} <=> $a->{finished} } @rows;
 
     print DEBUG "SORTED\n";
@@ -317,7 +317,7 @@ END
 
     foreach my $jr (@rows) {
        if ($wrote++ >= $limit) {
-           $write_cache_entry->($jr);
+           cache_write_entry(\*H, $jr);
            next;
        }
 
@@ -417,7 +417,7 @@ END
         print H "<td>" if !$any_power;
        print H "</td>\n";
 
-       $write_cache_entry->($jr);
+       cache_write_entry(\*H, $jr);
 
        print H "</tr>\n\n";
        $alternate ^= 1;
-- 
2.11.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.