-# $OpenBSD: Proc.pm,v 1.11 2016/05/03 19:13:04 bluhm Exp $
+# $OpenBSD: Proc.pm,v 1.12 2016/08/25 22:56:13 bluhm Exp $
-# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
+# Copyright (c) 2010-2016 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
or die "$class log file $self->{logfile} create failed: $!";
$fh->autoflush;
$self->{log} = $fh;
+ $self->{ppid} = $$;
return bless $self, $class;
}
my $self = shift;
my $flags = shift;
+ # if we a not the parent process, assume the child is still running
+ return 0 unless $self->{ppid} == $$;
+
my $pid = $self->{pid}
or croak ref($self), " no child pid";
my $kid = waitpid($pid, $flags);
-# $OpenBSD: Server.pm,v 1.9 2015/07/18 22:11:34 benno Exp $
+# $OpenBSD: Server.pm,v 1.10 2016/08/25 22:56:13 bluhm Exp $
# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
#
package Server;
use parent 'Proc';
use Carp;
+use Config;
use Socket;
use Socket6;
use IO::Socket;
pack('i', $self->{rcvbuf}))
or die ref($self), " set rcvbuf SO_RCVBUF failed: $!";
}
+ my $packstr = $Config{longsize} == 8 ? 'ql!' :
+ $Config{byteorder} == 1234 ? 'lxxxxl!' : 'xxxxll!';
if ($self->{sndtimeo}) {
setsockopt($ls, SOL_SOCKET, SO_SNDTIMEO,
- pack('l!l!', $self->{sndtimeo}, 0))
+ pack($packstr, $self->{sndtimeo}, 0))
or die ref($self), " set SO_SNDTIMEO failed failed: $!";
}
if ($self->{rcvtimeo}) {
setsockopt($ls, SOL_SOCKET, SO_RCVTIMEO,
- pack('l!l!', $self->{rcvtimeo}, 0))
+ pack($packstr, $self->{rcvtimeo}, 0))
or die ref($self), " set SO_RCVTIMEO failed failed: $!";
}
my $log = $self->{log};
use strict;
use warnings;
+use Errno ':POSIX';
+
+my @errors = (EWOULDBLOCK);
+my $errors = "(". join("|", map { $! = $_ } @errors). ")";
my $size = 2**21;
fast => 1,
max => 100,
func => sub {
- http_request(@_, $size, "1.0", "");
- http_response(@_, $size);
+ my $self = shift;
+ http_request($self , $size, "1.0", "");
+ http_response($self , $size);
print STDERR "going to sleep\n";
- sleep 8;
- read_char(@_, $size);
+ ${$self->{server}}->loggrep(qr/short write \($errors\)/, 8)
+ or die "no short write in server.log";
+ read_char($self, $size);
return;
},
- rcvbuf => 2**8,
+ rcvbuf => 2**12,
nocheck => 1,
},
relayd => {
server => {
fast => 1,
func => \&http_server,
- sndbuf => 2**8,
+ sndbuf => 2**12,
sndtimeo => 2,
loggrep => 'short write',
#!/usr/bin/perl
-# $OpenBSD: relayd.pl,v 1.14 2016/05/03 19:13:04 bluhm Exp $
+# $OpenBSD: relayd.pl,v 1.15 2016/08/25 22:56:13 bluhm Exp $
# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
#
redo => $redo,
%{$args{server}},
testfile => $testfile,
+ client => \$c,
) unless $args{server}{noserver};
$r = Relayd->new(
forward => $ARGV[0],
connectport => $rport,
%{$args{client}},
testfile => $testfile,
+ server => \$s,
) unless $args{client}{noclient};
$s->run unless $args{server}{noserver};
#!/usr/bin/perl
-# $OpenBSD: remote.pl,v 1.8 2016/05/03 19:13:04 bluhm Exp $
+# $OpenBSD: remote.pl,v 1.9 2016/08/25 22:56:13 bluhm Exp $
# Copyright (c) 2010-2014 Alexander Bluhm <bluhm@openbsd.org>
#
listenaddr => ($mode eq "auto" ? $ARGV[1] : undef),
listenport => ($mode eq "manual" ? $ARGV[0] : undef),
testfile => $testfile,
+ client => \$c,
) unless $args{server}{noserver};
if ($mode eq "auto") {
$r = Remote->new(
connectaddr => ($mode eq "manual" ? $ARGV[1] : $r->{listenaddr}),
connectport => ($mode eq "manual" ? $ARGV[2] : $r->{listenport}),
testfile => $testfile,
+ server => \$s,
) unless $args{client}{noclient};
$s->run unless $args{server}{noserver};