summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2006-03-08 11:22:03 +0000
committerMarc Espie <espie@cvs.openbsd.org>2006-03-08 11:22:03 +0000
commitaa348e4fadad6d83057511f21244ced70a93c6e6 (patch)
treedb367e0df2b1862baa3c86c3dd2861ab1b1b1716 /usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm
parent7c58ec5d2fa82ef5959dfc1408f22d1b1f1a4ccc (diff)
fix race condition in SCP for real.
We can't control a grand-child death through gzip, so stop spawning grand-children: create two children connected by hand through a pipe, and when we close gzip, explicitly wait for the second child to die as well. This avoids race conditions between sigpipe and sigusr1. (and as usual, the resulting code is easier to follow once you get through the pipe/fork). Thanks theo for the comment. ;-)
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm48
1 files changed, 1 insertions, 47 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm
index febc41c95c4..4a76a3154f3 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: SCP.pm,v 1.5 2006/03/07 14:18:51 espie Exp $
+# $OpenBSD: SCP.pm,v 1.6 2006/03/08 11:22:02 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -64,10 +64,6 @@ sub grab_object
my $cmdfh = $self->{cmdfh};
my $getfh = $self->{getfh};
- $SIG{'USR1'} = sub {
- kill USR1 => $object->{parent};
- exit(1);
- };
print $cmdfh "ABORT\n";
local $_;
@@ -103,22 +99,6 @@ sub grab_object
}
}
-sub pkg_copy
-{
- my ($self, $in, $object) = @_;
-
- $SIG{'USR1'} = sub {
- close($in);
- if (defined $object->{tempname}) {
- unlink $object->{tempname};
- }
- kill USR1 => $object->{parent};
- exit(1);
- };
-
- $self->SUPER::pkg_copy($in, $object);
-}
-
sub _new
{
my ($class, $baseurl) = @_;
@@ -173,32 +153,6 @@ sub list
return $self->{list};
}
-sub finish_and_close
-{
- my ($self, $object) = @_;
- $self->SUPER::close($object);
-}
-
-sub close
-{
- my ($self, $object, $hint) = @_;
- # XXX we have to make sure the grand-child is dead.
- if (defined $object->{pid2}) {
- my $received = 0;
- local $SIG{'USR1'} = sub { $received = 1; };
- kill USR1 => $object->{pid2};
- while (!$received) {
- sleep 0.01;
- }
- }
- close($object->{fh}) if defined $object->{fh};
-
- $self->parse_problems($object->{errors}, $hint)
- if defined $object->{errors};
- undef $object->{errors};
- $object->deref();
-}
-
# XXX not used yet
sub cleanup
{