Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some fixes for performance purpose

  • Loading branch information...
commit d4ee2e95c4f1ff750c2342de83defa5f571c035e 1 parent b158256
@cho45 authored
Showing with 12 additions and 10 deletions.
  1. +12 −10 lib/Starlet/Server.pm
View
22 lib/Starlet/Server.pm
@@ -347,19 +347,21 @@ sub write_all {
}
# show server-status like apache in ps title
-my @prev_status;
-sub server_status {
- my ($self, $key, @args) = @_;
- $ENV{SERVER_STATUS_CLASS} or return;
+BEGIN {
+ my $name = $ENV{SERVER_STATUS_CLASS};
+ if ($name) {
+ my $prev_status = "";
+ *server_status = sub {
+ my ($self, $key, $env) = @_;
+ if ($env) {
+ $prev_status = ref($env) ? join(" ", $env->{REMOTE_ADDR}, $env->{HTTP_HOST}, $env->{REQUEST_METHOD}, $env->{REQUEST_URI}, $env->{SERVER_PROTOCOL}) : $env;
+ }
- if (@args) {
- @prev_status = @args;
+ $0 = sprintf("server-status[%s] (req=%d) %s %s", $name, $self->{req_per_sec}, $key, $prev_status);
+ }
} else {
- @args = @prev_status;
+ *server_status = sub {}
}
-
- my $name = $ENV{SERVER_STATUS_CLASS};
- $0 = sprintf("server-status[%s] (r/s=%.1f) %s ", $name, $self->{req_per_sec}, $key) . join(" ", @args);
}
1;
Please sign in to comment.
Something went wrong with that request. Please try again.