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

[SCM] Debian package checker branch, master, updated. 2.5.9-27-g9e61a25



The following commit has been merged in the master branch:
commit ee65dc2511c5d06eb7fe1e978353f692de9c4d4b
Author: Niels Thykier <niels@thykier.net>
Date:   Wed Jun 27 17:52:35 2012 +0200

    lintian: Use WNOHANG to reduce waiting time
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/frontend/lintian b/frontend/lintian
index c83a9ba..2a2989c 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -1422,6 +1422,7 @@ sub unpack_group {
 
     while (1) {
         my $newjobs = 0;
+        my $nohang = 0;
         foreach my $proc ($group->get_processables){
             my $procid = $proc->identifier;
             my $wlist = $worklists{$procid};
@@ -1473,7 +1474,7 @@ sub unpack_group {
         # this package if any of the jobs failed.
         debug_msg(1, "Reaping done jobs ... unpack group $groupid");
 
-        while (my ($key, $cmd) = Lintian::Command::Simple::wait(\%running_jobs)) {
+        while (my ($key, $cmd) = Lintian::Command::Simple::wait(\%running_jobs, $nohang)) {
             my $jdata = $job_data{$key};
             my (undef, undef, $lpkg) = @$jdata;
             my $res;
@@ -1490,6 +1491,7 @@ sub unpack_group {
                 next;
             }
             $newjobs += $res;
+            $nohang = 1 if $res;
         }
         debug_msg(1, "Reap done jobs ... unpack group $groupid");
 
diff --git a/lib/Lintian/Command/Simple.pm b/lib/Lintian/Command/Simple.pm
index 5449328..be2f22f 100644
--- a/lib/Lintian/Command/Simple.pm
+++ b/lib/Lintian/Command/Simple.pm
@@ -18,6 +18,8 @@ package Lintian::Command::Simple;
 use strict;
 use warnings;
 
+use POSIX ":sys_wait_h";
+
 =head1 NAME
 
 Lintian::Command::Simple - Run commands without pipes
@@ -282,20 +284,23 @@ results.
 =cut
 
 sub wait {
-    my ($self, $pid);
+    my ($self, $pid, $nohang);
 
     if (ref $_[0] eq 'Lintian::Command::Simple') {
-        $self = shift;
+        ($self, $nohang) = @_;
         $pid = $self->{'pid'};
     } else {
-        $pid = shift;
+        ($pid, $nohang) = @_;
     }
 
+    $nohang = WNOHANG if $nohang;
+    $nohang //= 0;
+
     if (defined($pid) && !ref $pid) {
         $self->{'pid'} = undef
             if defined($self);
 
-        my $ret = waitpid($pid, 0);
+        my $ret = waitpid($pid, $nohang);
         my $status = $?;
 
         $self->{'status'} = $?
@@ -315,10 +320,10 @@ sub wait {
             return;
         }
 
-        $reaped_pid = CORE::wait();
+        $reaped_pid = waitpid(-1, $nohang);
         $reaped_status = $?;
 
-        if ($reaped_pid == -1) {
+        if ($reaped_pid == -1 or ($nohang and $reaped_pid == 0)) {
             return;
         }
 

-- 
Debian package checker


Reply to: