Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Some fixes for performance purpose

  • Loading branch information...
commit d4ee2e95c4f1ff750c2342de83defa5f571c035e 1 parent b158256
cho45 authored

Showing 1 changed file with 12 additions and 10 deletions. Show diff stats Hide diff stats

  1. +12 10 lib/Starlet/Server.pm
22 lib/Starlet/Server.pm
@@ -347,19 +347,21 @@ sub write_all {
347 347 }
348 348
349 349 # show server-status like apache in ps title
350   -my @prev_status;
351   -sub server_status {
352   - my ($self, $key, @args) = @_;
353   - $ENV{SERVER_STATUS_CLASS} or return;
  350 +BEGIN {
  351 + my $name = $ENV{SERVER_STATUS_CLASS};
  352 + if ($name) {
  353 + my $prev_status = "";
  354 + *server_status = sub {
  355 + my ($self, $key, $env) = @_;
  356 + if ($env) {
  357 + $prev_status = ref($env) ? join(" ", $env->{REMOTE_ADDR}, $env->{HTTP_HOST}, $env->{REQUEST_METHOD}, $env->{REQUEST_URI}, $env->{SERVER_PROTOCOL}) : $env;
  358 + }
354 359
355   - if (@args) {
356   - @prev_status = @args;
  360 + $0 = sprintf("server-status[%s] (req=%d) %s %s", $name, $self->{req_per_sec}, $key, $prev_status);
  361 + }
357 362 } else {
358   - @args = @prev_status;
  363 + *server_status = sub {}
359 364 }
360   -
361   - my $name = $ENV{SERVER_STATUS_CLASS};
362   - $0 = sprintf("server-status[%s] (r/s=%.1f) %s ", $name, $self->{req_per_sec}, $key) . join(" ", @args);
363 365 }
364 366
365 367 1;

0 comments on commit d4ee2e9

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