tweak logic of run slightly, so that we actually check stuff in finalize,
as should be. This also simplifies infinite jobs slightly, since we build the tasks we want directly
This commit is contained in:
parent
a58639ad7a
commit
61b975e3b2
@ -1,5 +1,5 @@
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: Core.pm,v 1.3 2010/02/27 09:53:09 espie Exp $
|
||||
# $OpenBSD: Core.pm,v 1.4 2010/03/01 17:59:49 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -171,7 +171,6 @@ sub terminate
|
||||
$self->task->end if $self->task;
|
||||
if ($self->SUPER::terminate) {
|
||||
$self->job->finalize($self);
|
||||
$self->mark_ready;
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,7 +212,7 @@ sub start_task
|
||||
if (defined $task) {
|
||||
return $core->run_task;
|
||||
} else {
|
||||
$core->job->finalize($core);
|
||||
return $core->job->finalize($core);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,13 +243,6 @@ package DPB::Job::Init;
|
||||
our @ISA = qw(DPB::Job::Normal);
|
||||
use DPB::Signature;
|
||||
|
||||
# no tasks for now
|
||||
sub next_task
|
||||
{
|
||||
my $self = shift;
|
||||
return pop(@{$self->{tasks}});
|
||||
}
|
||||
|
||||
sub new
|
||||
{
|
||||
my $class = shift;
|
||||
@ -459,12 +451,6 @@ sub start_pipe
|
||||
$self->start_job(DPB::Job::Pipe->new($code, $name));
|
||||
}
|
||||
|
||||
sub start
|
||||
{
|
||||
my ($self, $code, $endcode, $name) = @_;
|
||||
$self->start_job(DPB::Job::Normal->new($code, $endcode, $name));
|
||||
}
|
||||
|
||||
package DPB::Core::Special;
|
||||
our @ISA = qw(DPB::Core::WithJobs);
|
||||
sub repository
|
||||
@ -484,19 +470,6 @@ sub host
|
||||
return $host;
|
||||
}
|
||||
|
||||
package DPB::Job::Clock;
|
||||
our @ISA = qw(DPB::Job::Infinite);
|
||||
|
||||
sub new
|
||||
{
|
||||
my ($class, $timeout) = @_;
|
||||
$timeout //= 10;
|
||||
return $class->SUPER::new(sub {
|
||||
sleep($timeout);
|
||||
exit(0);
|
||||
}, 'clock');
|
||||
}
|
||||
|
||||
package DPB::Core::Clock;
|
||||
our @ISA = qw(DPB::Core::Special);
|
||||
|
||||
@ -504,7 +477,11 @@ sub start
|
||||
{
|
||||
my ($class, $timeout) = @_;
|
||||
my $core = $class->new('localhost');
|
||||
$core->start_job(DPB::Job::Clock->new($timeout));
|
||||
$timeout //= 10;
|
||||
$core->start_job(DPB::Job::Infinite->new(DPB::Task::Fork->new(sub {
|
||||
sleep($timeout);
|
||||
exit(0);
|
||||
}), 'clock'));
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: Distant.pm,v 1.2 2010/02/26 12:14:57 espie Exp $
|
||||
# $OpenBSD: Distant.pm,v 1.3 2010/03/01 17:59:49 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -72,6 +72,36 @@ sub make
|
||||
return OpenBSD::Paths->make;
|
||||
}
|
||||
|
||||
package DPB::Task::SshMaster;
|
||||
our @ISA = qw(DPB::Task::Fork);
|
||||
sub run
|
||||
{
|
||||
my $self = shift;
|
||||
my $socket = $self->{socket};
|
||||
my $timeout = $self->{timeout};
|
||||
my $host = $self->{host};
|
||||
close STDOUT;
|
||||
close STDERR;
|
||||
open STDOUT, '>/dev/null';
|
||||
open STDERR, '>&STDOUT';
|
||||
exec {OpenBSD::Paths->ssh}
|
||||
(DPB::Ssh->ssh($socket, $timeout),
|
||||
'-N', '-M', $host);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
# we never error out
|
||||
sub finalize
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub new
|
||||
{
|
||||
my ($class, $socket, $timeout, $host) = @_;
|
||||
bless {socket => $socket, timeout => $timeout, host => $host}, $class;
|
||||
}
|
||||
|
||||
package DPB::Job::SshMaster;
|
||||
our @ISA = qw(DPB::Job::Infinite);
|
||||
|
||||
@ -82,16 +112,8 @@ sub new
|
||||
$TMPDIR //= $ENV{PKG_TMPDIR} || '/var/tmp';
|
||||
my $timeout = 60;
|
||||
my $socket = "$TMPDIR/ssh-$host-$$";
|
||||
my $o = $class->SUPER::new(sub {
|
||||
close STDOUT;
|
||||
close STDERR;
|
||||
open STDOUT, '>/dev/null';
|
||||
open STDERR, '>&STDOUT';
|
||||
exec {OpenBSD::Paths->ssh}
|
||||
(DPB::Ssh->ssh($socket, $timeout),
|
||||
'-N', '-M', $host);
|
||||
exit(1);
|
||||
}, "ssh master for $host");
|
||||
my $o = $class->SUPER::new(DPB::Task::SshMaster->new($socket,
|
||||
$timeout, $host), "ssh master for $host");
|
||||
$o->{host} = $host;
|
||||
$o->{timeout} = $timeout;
|
||||
$o->{socket} = $socket;
|
||||
|
@ -1,5 +1,5 @@
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: Engine.pm,v 1.2 2010/02/26 12:14:57 espie Exp $
|
||||
# $OpenBSD: Engine.pm,v 1.3 2010/03/01 17:59:49 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -156,11 +156,12 @@ sub important
|
||||
{
|
||||
my $self = shift;
|
||||
$self->{lasterrors} //= 0;
|
||||
if (@{$self->{errors}} > $self->{lasterrors}) {
|
||||
my $i = 0;
|
||||
my $i = @{$self->{errors}} - $self->{lasterrors};
|
||||
if ($i > 0) {
|
||||
my @msg;
|
||||
my $j = 0;
|
||||
for my $v (@{$self->{errors}}) {
|
||||
next if $i++ >= $self->{lasterrors};
|
||||
last if $j++ > $i;
|
||||
push(@msg, $v->fullpkgpath);
|
||||
}
|
||||
$self->{lasterrors} = @{$self->{errors}};
|
||||
|
@ -1,5 +1,5 @@
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: Job.pm,v 1.2 2010/02/26 12:14:57 espie Exp $
|
||||
# $OpenBSD: Job.pm,v 1.3 2010/03/01 17:59:49 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -51,7 +51,7 @@ sub process
|
||||
sub finalize
|
||||
{
|
||||
my ($self, $core) = @_;
|
||||
return 1;
|
||||
return $core->{status} == 0;
|
||||
}
|
||||
|
||||
package DPB::Task::Pipe;
|
||||
@ -81,11 +81,7 @@ package DPB::Job;
|
||||
sub next_task
|
||||
{
|
||||
my ($self, $core) = @_;
|
||||
if ($core->{status} == 0) {
|
||||
return shift @{$self->{tasks}};
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
return shift @{$self->{tasks}};
|
||||
}
|
||||
|
||||
sub name
|
||||
@ -148,9 +144,9 @@ sub next_task
|
||||
|
||||
sub new
|
||||
{
|
||||
my ($class, $code, $name) = @_;
|
||||
my ($class, $task, $name) = @_;
|
||||
my $o = $class->SUPER::new($name);
|
||||
$o->{task} = DPB::Task::Fork->new($code);
|
||||
$o->{task} = $task;
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user