diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2012-07-09 14:23:18 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2012-07-09 14:23:18 +0000 |
commit | f996687abc85710d80fd98ff39d29ab539f5708e (patch) | |
tree | c535e5f939a93f98575eed91bb9f2c9395f8c1de /regress/sys | |
parent | 7cb630b194ce4146425a7eea38c1c04b701b101d (diff) |
Modern Perl deferes signal handlers between opcodes. To send TCP
resets at the indended moments into the spliced stream, terminate
the client or server process with the alarm default action.
Diffstat (limited to 'regress/sys')
-rw-r--r-- | regress/sys/kern/splice/Client.pm | 7 | ||||
-rw-r--r-- | regress/sys/kern/splice/Proc.pm | 14 | ||||
-rw-r--r-- | regress/sys/kern/splice/args-reset-sleep-server.pl | 4 | ||||
-rw-r--r-- | regress/sys/kern/splice/args-server-abort.pl | 3 | ||||
-rwxr-xr-x | regress/sys/kern/splice/echo.pl | 6 | ||||
-rw-r--r-- | regress/sys/kern/splice/funcs.pl | 4 |
6 files changed, 22 insertions, 16 deletions
diff --git a/regress/sys/kern/splice/Client.pm b/regress/sys/kern/splice/Client.pm index 74f3b866e93..f17f7f5129f 100644 --- a/regress/sys/kern/splice/Client.pm +++ b/regress/sys/kern/splice/Client.pm @@ -1,6 +1,6 @@ -# $OpenBSD: Client.pm,v 1.1 2011/01/07 22:06:08 bluhm Exp $ +# $OpenBSD: Client.pm,v 1.2 2012/07/09 14:23:17 bluhm Exp $ -# Copyright (c) 2010 Alexander Bluhm <bluhm@openbsd.org> +# Copyright (c) 2010-2012 Alexander Bluhm <bluhm@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -30,7 +30,8 @@ sub new { my %args = @_; $args{logfile} ||= "client.log"; $args{up} ||= "Connected"; - $args{down} ||= "Shutdown|Broken pipe|Connection reset by peer"; + $args{down} ||= $args{alarm} ? "Alarm" : + "Shutdown|Broken pipe|Connection reset by peer"; my $self = Proc::new($class, %args); $self->{connectdomain} or croak "$class connect domain not given"; diff --git a/regress/sys/kern/splice/Proc.pm b/regress/sys/kern/splice/Proc.pm index 8e1838f00d1..2b64b64d5bb 100644 --- a/regress/sys/kern/splice/Proc.pm +++ b/regress/sys/kern/splice/Proc.pm @@ -1,6 +1,6 @@ -# $OpenBSD: Proc.pm,v 1.2 2011/08/28 13:27:35 bluhm Exp $ +# $OpenBSD: Proc.pm,v 1.3 2012/07/09 14:23:17 bluhm Exp $ -# Copyright (c) 2010 Alexander Bluhm <bluhm@openbsd.org> +# Copyright (c) 2010-2012 Alexander Bluhm <bluhm@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -42,13 +42,14 @@ END { sub new { my $class = shift; my $self = { @_ }; - $self->{down} ||= "Shutdown"; + $self->{down} ||= $self->{alarm} ? "Alarm" : "Shutdown"; $self->{func} && ref($self->{func}) eq 'CODE' or croak "$class func not given"; $self->{logfile} or croak "$class log file not given"; open(my $fh, '>', $self->{logfile}) or die "$class log file $self->{logfile} create failed: $!"; + $fh->autoflush; $self->{log} = $fh; return bless $self, $class; } @@ -76,6 +77,7 @@ sub run { $self->child(); print STDERR $self->{up}, "\n"; + alarm($self->{alarm}) if $self->{alarm}; $self->{func}->($self); print STDERR "Shutdown", "\n"; IO::Handle::flush(\*STDOUT); @@ -110,7 +112,11 @@ sub loggrep { do { my($kid, $status, $code) = $self->wait(WNOHANG); - if ($kid > 0 && $status != 0) { + if ($self->{alarm} && $kid > 0 && + WIFSIGNALED($status) && WTERMSIG($status) == 14 ) { + # child killed by SIGALRM as expected + print {$self->{log}} "Alarm", "\n"; + } elsif ($kid > 0 && $status != 0) { # child terminated with failure die ref($self), " child status: $status $code"; } diff --git a/regress/sys/kern/splice/args-reset-sleep-server.pl b/regress/sys/kern/splice/args-reset-sleep-server.pl index 2e1a8f8ecc2..c72726732f1 100644 --- a/regress/sys/kern/splice/args-reset-sleep-server.pl +++ b/regress/sys/kern/splice/args-reset-sleep-server.pl @@ -5,8 +5,8 @@ use warnings; our %args = ( client => { - func => sub { $SIG{ALRM} = sub { print STDERR "\nShutdown\n"; exit 0 }; - solingerout(@_); alarm(1); write_char(@_); }, + alarm => 1, + func => sub { solingerout(@_); write_char(@_); }, len => 2**19, nocheck => 1, }, diff --git a/regress/sys/kern/splice/args-server-abort.pl b/regress/sys/kern/splice/args-server-abort.pl index f88e29cbdd7..a2a98acbc4d 100644 --- a/regress/sys/kern/splice/args-server-abort.pl +++ b/regress/sys/kern/splice/args-server-abort.pl @@ -23,8 +23,7 @@ our %args = ( errorout => 54, }, server => { - func => sub { $SIG{ALRM} = sub { print STDERR "\nShutdown\n"; exit 0 }; - alarm(3); read_char(@_); }, + alarm => 3, nocheck => 1, }, noecho => 1, diff --git a/regress/sys/kern/splice/echo.pl b/regress/sys/kern/splice/echo.pl index f46cad6312c..4c8e60809e4 100755 --- a/regress/sys/kern/splice/echo.pl +++ b/regress/sys/kern/splice/echo.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -# $OpenBSD: echo.pl,v 1.5 2011/08/21 22:50:59 bluhm Exp $ +# $OpenBSD: echo.pl,v 1.6 2012/07/09 14:23:17 bluhm Exp $ -# Copyright (c) 2010 Alexander Bluhm <bluhm@openbsd.org> +# Copyright (c) 2010-2012 Alexander Bluhm <bluhm@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -38,7 +38,7 @@ if (@ARGV and -f $ARGV[-1]) { } @ARGV == 1 or usage(); -exit 0 if $args{noecho}; +exit 0 if $args{noecho} || $args{client}{alarm} || $args{server}{alarm}; my $r = Server->new( forward => $ARGV[0], diff --git a/regress/sys/kern/splice/funcs.pl b/regress/sys/kern/splice/funcs.pl index 5490eee0d36..03c6a710ed1 100644 --- a/regress/sys/kern/splice/funcs.pl +++ b/regress/sys/kern/splice/funcs.pl @@ -1,6 +1,6 @@ -# $OpenBSD: funcs.pl,v 1.9 2012/07/09 09:48:04 bluhm Exp $ +# $OpenBSD: funcs.pl,v 1.10 2012/07/09 14:23:17 bluhm Exp $ -# Copyright (c) 2010,2011 Alexander Bluhm <bluhm@openbsd.org> +# Copyright (c) 2010-2012 Alexander Bluhm <bluhm@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above |