summaryrefslogtreecommitdiff
path: root/regress/sys
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2012-07-09 09:48:05 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2012-07-09 09:48:05 +0000
commit61b0016eb3e43565566885c0d8dd445fef26b4b9 (patch)
treec223de17a0ab338af9b5c9130e1019568115b5ad /regress/sys
parentbf74915ff70bba0b9075646f992943c92e466576 (diff)
Add a socket splicing test that sends a reset from the client while
the socket buffers are filled.
Diffstat (limited to 'regress/sys')
-rw-r--r--regress/sys/kern/splice/args-reset-eof.pl2
-rw-r--r--regress/sys/kern/splice/args-reset-sleep-server.pl28
-rw-r--r--regress/sys/kern/splice/args-reset.pl2
-rw-r--r--regress/sys/kern/splice/funcs.pl21
4 files changed, 47 insertions, 6 deletions
diff --git a/regress/sys/kern/splice/args-reset-eof.pl b/regress/sys/kern/splice/args-reset-eof.pl
index 11665fc628e..fc94f5ffead 100644
--- a/regress/sys/kern/splice/args-reset-eof.pl
+++ b/regress/sys/kern/splice/args-reset-eof.pl
@@ -5,7 +5,7 @@ use warnings;
our %args = (
server => {
- func => sub { read_char(@_); sleep 3; solinger(@_); },
+ func => sub { read_char(@_); sleep 3; solingerin(@_); },
},
);
diff --git a/regress/sys/kern/splice/args-reset-sleep-server.pl b/regress/sys/kern/splice/args-reset-sleep-server.pl
new file mode 100644
index 00000000000..2e1a8f8ecc2
--- /dev/null
+++ b/regress/sys/kern/splice/args-reset-sleep-server.pl
@@ -0,0 +1,28 @@
+# test delay before server read, client sends reset during splice
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => sub { $SIG{ALRM} = sub { print STDERR "\nShutdown\n"; exit 0 };
+ solingerout(@_); alarm(1); write_char(@_); },
+ len => 2**19,
+ nocheck => 1,
+ },
+ relay => {
+ func => sub { errignore(@_); relay(@_); },
+ rcvbuf => 2**10,
+ sndbuf => 2**10,
+ down => "Broken pipe|Connection reset by peer",
+ nocheck => 1,
+ },
+ server => {
+ func => sub { sleep 3; read_char(@_); },
+ nocheck => 1,
+ },
+ len => 131072,
+ md5 => "31e5ad3d0d2aeb1ad8aaa847dfa665c2",
+);
+
+1;
diff --git a/regress/sys/kern/splice/args-reset.pl b/regress/sys/kern/splice/args-reset.pl
index 319425c5053..3edfcfafd4c 100644
--- a/regress/sys/kern/splice/args-reset.pl
+++ b/regress/sys/kern/splice/args-reset.pl
@@ -15,7 +15,7 @@ our %args = (
down => "Broken pipe|Connection reset by peer",
},
server => {
- func => sub { sleep 3; solinger(@_); },
+ func => sub { sleep 3; solingerin(@_); },
rcvbuf => 2**12,
},
nocheck => 1,
diff --git a/regress/sys/kern/splice/funcs.pl b/regress/sys/kern/splice/funcs.pl
index 5af45a33e37..5490eee0d36 100644
--- a/regress/sys/kern/splice/funcs.pl
+++ b/regress/sys/kern/splice/funcs.pl
@@ -1,4 +1,4 @@
-# $OpenBSD: funcs.pl,v 1.8 2011/08/29 01:50:38 bluhm Exp $
+# $OpenBSD: funcs.pl,v 1.9 2012/07/09 09:48:04 bluhm Exp $
# Copyright (c) 2010,2011 Alexander Bluhm <bluhm@openbsd.org>
#
@@ -111,6 +111,13 @@ sub write_oob {
print STDERR "MD5: ", $ctx->hexdigest, "\n";
}
+sub solingerout {
+ my $self = shift;
+
+ setsockopt(STDOUT, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0))
+ or die ref($self), " set linger out failed: $!";
+}
+
########################################################################
# Relay funcs
########################################################################
@@ -176,7 +183,13 @@ sub relay_copy {
or die ref($self),
" select write failed: $!";
}
- my $write = syswrite(STDOUT, $buf, $read - $off, $off);
+ my $write;
+ # Unfortunately Perl installs signal handlers without
+ # SA_RESTART. Work around by restarting manually.
+ do {
+ $write = syswrite(STDOUT, $buf, $read - $off,
+ $off);
+ } while (!defined($write) && $!{EINTR});
defined($write) || $!{ETIMEDOUT}
or die ref($self), " syswrite at $len failed: $!";
defined($write) or next;
@@ -389,11 +402,11 @@ sub read_oob {
print STDERR "MD5: ", $ctx->hexdigest, "\n";
}
-sub solinger {
+sub solingerin {
my $self = shift;
setsockopt(STDIN, SOL_SOCKET, SO_LINGER, pack('ii', 1, 0))
- or die ref($self), " set linger failed: $!";
+ or die ref($self), " set linger in failed: $!";
}
1;