diff options
author | Eric Wong <e@80x24.org> | 2019-06-24 02:52:14 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-24 05:26:26 +0000 |
commit | 2929e3b3c62925149a9a8cafd872bfdb017453eb (patch) | |
tree | bc457eb555014fe3c3c09b6d8b926807c0dc0e5a /lib/PublicInbox/HTTP.pm | |
parent | e1b203f218b3fedea3068d6265130c47f0af9f4c (diff) | |
download | public-inbox-2929e3b3c62925149a9a8cafd872bfdb017453eb.tar.gz |
Data which can't fit into a generously-sized socket buffer, has no business being stored in heap.
Diffstat (limited to 'lib/PublicInbox/HTTP.pm')
-rw-r--r-- | lib/PublicInbox/HTTP.pm | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index a669eb6e..fcb5eb6c 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -19,7 +19,7 @@ use HTTP::Status qw(status_message); use HTTP::Date qw(time2str); use IO::Handle; require PublicInbox::EvCleanup; -PublicInbox::DS->import('msg_more'); +PublicInbox::DS->import(qw(msg_more write_in_full)); use constant { CHUNK_START => -1, # [a-f0-9]+\r\n CHUNK_END => -2, # \r\n @@ -125,7 +125,7 @@ sub read_input ($) { while ($len > 0) { if ($$rbuf ne '') { - my $w = write_in_full($input, $rbuf, $len); + my $w = write_in_full($input, $rbuf, $len, 0); return write_err($self, $len) unless $w; $len -= $w; die "BUG: $len < 0 (w=$w)" if $len < 0; @@ -367,20 +367,6 @@ sub recv_err { quit($self, 500); } -sub write_in_full { - my ($fh, $rbuf, $len) = @_; - my $rv = 0; - my $off = 0; - while ($len > 0) { - my $w = syswrite($fh, $$rbuf, $len, $off); - return ($rv ? $rv : $w) unless $w; # undef or 0 - $rv += $w; - $off += $w; - $len -= $w; - } - $rv -} - sub read_input_chunked { # unlikely... my ($self) = @_; my $input = $self->{env}->{'psgi.input'}; @@ -425,7 +411,7 @@ sub read_input_chunked { # unlikely... # drain the current chunk until ($len <= 0) { if ($$rbuf ne '') { - my $w = write_in_full($input, $rbuf, $len); + my $w = write_in_full($input, $rbuf, $len, 0); return write_err($self, "$len chunk") if !$w; $len -= $w; if ($len == 0) { |