have both log watching jobs actually share the timeout code.

If I had done this before, I would have fixed kill just once after privsep
and not inadvertently broken the builder stuck timeout...

problem noticed by naddy@
This commit is contained in:
espie 2017-04-14 16:43:40 +00:00
parent 422ed0448d
commit 22d7bcaa17
3 changed files with 29 additions and 25 deletions

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Job.pm,v 1.10 2014/12/07 15:18:50 espie Exp $
# $OpenBSD: Job.pm,v 1.11 2017/04/14 16:43:40 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -131,6 +131,18 @@ sub watched
return $self->{status};
}
# abstract method, to be used by jobs that have actual watch limits
sub kill_on_timeout
{
my ($self, $diff, $core, $msg) = @_;
my $to = $self->get_timeout($core);
return $msg if !defined $to || $diff <= $to;
local $> = 0; # XXX switch to root, we don't know for sure which
# user owns the pid (not really an issue)
kill 9, $core->{pid};
return $self->{stuck} = "KILLED: $self->{current} stuck at $msg";
}
sub add_tasks
{
my ($self, @tasks) = @_;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Fetch.pm,v 1.11 2015/05/18 16:35:15 espie Exp $
# $OpenBSD: Fetch.pm,v 1.12 2017/04/14 16:43:40 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -233,17 +233,13 @@ sub watched
my $w = $self->{watched};
my $diff = $w->check_change($current);
my $msg = $w->percent_message . $w->frozen_message($diff);
my $to = $core->fetch_timeout;
if (defined $to) {
if ($diff > $to) {
$self->{stuck} =
"KILLED: $self->{current} stuck at $msg";
local $> = 0;
kill 9, $core->{pid};
return $self->{stuck};
}
}
return $msg;
return $self->kill_on_timeout($diff, $core, $msg);
}
sub get_timeout
{
my ($self, $core) = @_;
return $core->fetch_timeout;
}
1;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Port.pm,v 1.168 2015/11/20 13:49:08 espie Exp $
# $OpenBSD: Port.pm,v 1.169 2017/04/14 16:43:40 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -1064,17 +1064,13 @@ sub watched
if ($self->{task}->want_frozen) {
$msg .= $w->frozen_message($diff);
}
my $stuck = $core->stuck_timeout;
if (defined $stuck) {
if ($diff > $stuck) {
local $> = 0;
$self->{stuck} =
"KILLED: $self->{current} stuck at $msg";
kill 9, $core->{pid};
return $self->{stuck};
}
}
return $msg;
return $self->kill_on_timeout($diff, $core, $msg);
}
sub get_timeout
{
my ($self, $core) = @_;
return $core->stuck_timeout;
}
sub really_watch