diff --git a/lib/Starman/Server.pm b/lib/Starman/Server.pm index e03f2e7..30bce9d 100644 --- a/lib/Starman/Server.pm +++ b/lib/Starman/Server.pm @@ -210,6 +210,8 @@ sub process_request { or die $!; } + my $keepalive_requests = 0; + while ( $self->{client}->{keepalive} ) { last if !$conn->connected; @@ -322,6 +324,10 @@ sub process_request { } } + if (exists $self->{options}->{max_keepalive_requests}) { + last if ++$keepalive_requests >= $self->{options}->{max_keepalive_requests}; + } + DEBUG && warn "[$$] Waiting on previous connection for keep-alive request...\n"; my $sel = IO::Select->new($conn); diff --git a/script/starman b/script/starman index 52d877f..0d4c819 100755 --- a/script/starman +++ b/script/starman @@ -122,6 +122,16 @@ failover (see above). Number of the requests to process per one worker process. Defaults to 1000. +Note that "requests" actually means "connections served by a worker". +In presence of Keep-alive a worker process can actually serve more +requests; this can only be limited with the +C<--max-keepalive-requests> option. + +=item --max-keepalive-requests + +Maximum number of Keep-alive requests served for a connection. By +default there's no limit. + =item --preload-app This option lets Starman preload the specified PSGI application in the