Skip to content

Commit

Permalink
Do not call eval in every request
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er committed Nov 13, 2016
1 parent 9b39eec commit 0b33e36
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/HTTP/Server/PSGI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ use Plack::Util;
use Stream::Buffered;
use Plack::Middleware::ContentLength;
use POSIX qw(EINTR);
use Socket qw(IPPROTO_TCP TCP_NODELAY);
use Socket qw(IPPROTO_TCP);

use Try::Tiny;
use Time::HiRes qw(time);

use constant TCP_NODELAY => try { Socket::TCP_NODELAY };

my $alarm_interval;
BEGIN {
if ($^O eq 'MSWin32') {
Expand Down Expand Up @@ -105,7 +107,7 @@ sub accept_loop {
while (1) {
local $SIG{PIPE} = 'IGNORE';
if (my $conn = $self->{listen_sock}->accept) {
if (eval { TCP_NODELAY }) {
if (defined TCP_NODELAY) {
$conn->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
or die "setsockopt(TCP_NODELAY) failed:$!";
}
Expand Down

0 comments on commit 0b33e36

Please sign in to comment.