Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 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,8 +107,10 @@ sub accept_loop {
while (1) {
local $SIG{PIPE} = 'IGNORE';
if (my $conn = $self->{listen_sock}->accept) {
$conn->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
or die "setsockopt(TCP_NODELAY) failed:$!";
if (defined TCP_NODELAY) {
$conn->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
or die "setsockopt(TCP_NODELAY) failed:$!";
}
my $env = {
SERVER_PORT => $self->{port},
SERVER_NAME => $self->{host},
Expand Down