# HG changeset patch # User Maxim Dounin # Date 1466775008 -10800 # Node ID d4a0232425ee5d6be3616bb42ebe844717ecd5fb # Parent 508ee7ea97065ecfad040b2f96f88bcaa405c9a5 Tests: fixed race in SCGI tests. diff --git a/scgi.t b/scgi.t --- a/scgi.t +++ b/scgi.t @@ -64,7 +64,7 @@ http { EOF $t->run_daemon(\&scgi_daemon); -$t->run(); +$t->run()->waitforsocket('127.0.0.1:' . port(1)); ############################################################################### @@ -126,8 +126,10 @@ sub scgi_daemon { my $count = 0; while (my $request = $scgi->accept()) { + eval { $request->read_env(); }; + next if $@; + $count++; - $request->read_env(); $request->connection()->print(<run_daemon(\&scgi_daemon); -$t->run(); +$t->run()->waitforsocket('127.0.0.1:' . port(1)); ############################################################################### @@ -114,7 +114,9 @@ sub scgi_daemon { my $body; while (my $request = $scgi->accept()) { - $request->read_env(); + eval { $request->read_env(); }; + next if $@; + read($request->connection, $body, $request->env->{CONTENT_LENGTH}); diff --git a/scgi_cache.t b/scgi_cache.t --- a/scgi_cache.t +++ b/scgi_cache.t @@ -59,7 +59,7 @@ http { EOF $t->run_daemon(\&scgi_daemon); -$t->run(); +$t->run()->waitforsocket('127.0.0.1:' . port(1)); ############################################################################### @@ -93,7 +93,8 @@ sub scgi_daemon { my %count; while (my $request = $scgi->accept()) { - $request->read_env(); + eval { $request->read_env(); }; + next if $@; my $uri = $request->env->{REQUEST_URI} || ''; my $c = $request->connection(); diff --git a/scgi_gzip.t b/scgi_gzip.t --- a/scgi_gzip.t +++ b/scgi_gzip.t @@ -54,7 +54,7 @@ http { EOF $t->run_daemon(\&scgi_daemon); -$t->run(); +$t->run()->waitforsocket('127.0.0.1:' . port(1)); ############################################################################### @@ -74,7 +74,8 @@ sub scgi_daemon { my $scgi = SCGI->new($server, blocking => 1); while (my $request = $scgi->accept()) { - $request->read_env(); + eval { $request->read_env(); }; + next if $@; $request->connection()->print(<run_daemon(\&scgi_daemon); -$t->run(); +$t->run()->waitforsocket('127.0.0.1:' . port(1)); ############################################################################### @@ -122,11 +122,10 @@ sub scgi_daemon { or die "Can't create listening socket: $!\n"; my $scgi = SCGI->new($server, blocking => 1); - my $count = 0; while (my $request = $scgi->accept()) { - $count++; - $request->read_env(); + eval { $request->read_env(); }; + next if $@; my $ims = $request->env->{HTTP_IF_MODIFIED_SINCE} || ''; my $iums = $request->env->{HTTP_IF_UNMODIFIED_SINCE} || '';