Author: Niko Tyni Description: fix the detach test on systems with a large socket buffer size (#584344) --- speedy-cgi-perl.orig/speedy/t/detach.t +++ speedy-cgi-perl/speedy/t/detach.t @@ -6,9 +6,22 @@ use strict; use IO::File; +use Socket; my $smbuf = 8 * 1024; -my $lgbuf = 512 * 1024; +my $lgbuf; + +# find out the size of the socket write buffer +# see http://bugs.debian.org/584344 +my $s; +if (socket($s, AF_UNIX, SOCK_STREAM, 0) && + (my $packed_size = getsockopt($s, SOL_SOCKET, SO_SNDBUF))) { + $lgbuf = $smbuf + 2 * unpack("I", $packed_size); +} else { + warn("socket() or getsockopt() failed: $!"); +} + +$lgbuf = 512 * 1024 if $lgbuf < 512 * 1024; my $scr = 't/scripts/detach'; use vars qw(@open_files @pids %children); @@ -23,7 +36,7 @@ $| = 1; print ""; $| = 0; my $child; if (($child = open($fh, "-|")) == 0) { - open(F, "$ENV{SPEEDY} -- -B$sz $scr |"); + open(F, "$ENV{SPEEDY} -- -B$sz $scr $lgbuf |"); print scalar ; close(STDOUT); sleep 60; # Simulate slow drain of output --- speedy-cgi-perl.orig/speedy/t/scripts/detach +++ speedy-cgi-perl/speedy/t/scripts/detach @@ -1,3 +1,6 @@ $| = 1; +# the data should not fit in the socket write buffer +# see http://bugs.debian.org/584344 +my $size = shift || (512 * 1024); print "$$\n"; -print 'x' x (500*1024); +print 'x' x int(500 / 512 * $size);