Skip to content

Commit

Permalink
ssl socket could not write content of 16KB or more in a single syswrite
Browse files Browse the repository at this point in the history
  • Loading branch information
kazeburo committed Aug 13, 2013
1 parent c73cc9d commit 4080365
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/Starman/Server.pm
Expand Up @@ -516,7 +516,11 @@ sub _finalize_response {
return unless $len;
$buffer = sprintf( "%x", $len ) . $CRLF . $buffer . $CRLF;
}
syswrite $conn, $buffer;
while ( length $buffer ) {
my $len = syswrite $conn, $buffer;
die "write error: $!" if ! defined $len;
substr( $buffer, 0, $len, '');
}
DEBUG && warn "[$$] Wrote " . length($buffer) . " bytes\n";
});

Expand All @@ -530,7 +534,11 @@ sub _finalize_response {
return unless $len;
$buffer = sprintf( "%x", $len ) . $CRLF . $buffer . $CRLF;
}
syswrite $conn, $buffer;
while ( length $buffer ) {
my $len = syswrite $conn, $buffer;
die "write error: $!" if ! defined $len;
substr( $buffer, 0, $len, '');
}
DEBUG && warn "[$$] Wrote " . length($buffer) . " bytes\n";
},
close => sub {
Expand Down

0 comments on commit 4080365

Please sign in to comment.