Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

I _think_ srand() should come before compiling the .psgi file in the …

…non-preload mode.
  • Loading branch information...
commit c0bbf1303643ee893751b68d1d19f015f59f1b6e 1 parent 61a8233
@miyagawa authored
Showing with 19 additions and 13 deletions.
  1. +1 −1  lib/Starman/Server.pm
  2. +18 −12 t/rand.t
View
2  lib/Starman/Server.pm
@@ -104,11 +104,11 @@ sub run_parent {
sub child_init_hook {
my $self = shift;
+ srand();
if ($self->{options}->{psgi_app_builder}) {
DEBUG && warn "[$$] Initializing the PSGI app\n";
$self->{app} = $self->{options}->{psgi_app_builder}->();
}
- srand();
$0 = "starman worker " . join(" ", @{$self->{options}{argv} || []});
}
View
30 t/rand.t
@@ -3,20 +3,26 @@ use LWP::UserAgent;
use FindBin;
use Test::More;
-my $s = Test::TCP->new(
- code => sub {
- my $port = shift;
- exec "$^X bin/starman --preload-app --port $port --max-requests=1 --workers=1 $FindBin::Bin/rand.psgi";
- },
-);
+for (1..2) { # preload, non-preload
+ my $preload = $_ == 1 ? "--preload-app" : "";
-my $ua = LWP::UserAgent->new;
+ my $s = Test::TCP->new(
+ code => sub {
+ my $port = shift;
+ exec "$^X bin/starman $preload --port $port --max-requests=1 --workers=1 $FindBin::Bin/rand.psgi";
+ },
+ );
-my @res;
-for (1..2) {
- push @res, $ua->get("http://localhost:" . $s->port);
-}
+ my $ua = LWP::UserAgent->new;
+
+ my @res;
+ for (1..2) {
+ push @res, $ua->get("http://localhost:" . $s->port);
+ }
-isnt $res[0]->content, $res[1]->content;
+ isnt $res[0]->content, $res[1]->content;
+
+ undef $s;
+}
done_testing;

0 comments on commit c0bbf13

Please sign in to comment.
Something went wrong with that request. Please try again.