diff options
author | Eric Wong <e@80x24.org> | 2019-06-24 02:52:35 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-24 05:26:26 +0000 |
commit | a3c27256d273492e1c9ee464dabda2c7ed4019c2 (patch) | |
tree | 5ef3efbb78bbed93f9d5bb7f2f11e43f26fd7bca /lib/PublicInbox/GitHTTPBackend.pm | |
parent | 6b1ee7ed8032e277a84bbe2a343f2c318a0defb8 (diff) | |
download | public-inbox-a3c27256d273492e1c9ee464dabda2c7ed4019c2.tar.gz |
It may make sense to use PerlIO::mmap or PerlIO::scalar for DS write buffering with IO::Socket::SSL or similar (since we can't use MSG_MORE), so that means we need to go through buffering in userspace for the common case; while still being easily compatible with slow clients. And it also simplifies GitHTTPBackend slightly. Maybe it can make sense for HTTP input buffering, too...
Diffstat (limited to 'lib/PublicInbox/GitHTTPBackend.pm')
-rw-r--r-- | lib/PublicInbox/GitHTTPBackend.pm | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm index a2a81f8e..303d5073 100644 --- a/lib/PublicInbox/GitHTTPBackend.pm +++ b/lib/PublicInbox/GitHTTPBackend.pm @@ -231,18 +231,16 @@ sub input_prepare { return; } last if $r == 0; - my $off = 0; - while ($r > 0) { - my $w = syswrite($in, $buf, $r, $off); - if (defined $w) { - $r -= $w; - $off += $w; - } else { - err($env, "error writing temporary file: $!"); - return; - } + unless (print $in $buf) { + err($env, "error writing temporary file: $!"); + return; } } + # ensure it's visible to git-http-backend(1): + unless ($in->flush) { + err($env, "error writing temporary file: $!"); + return; + } unless (defined(sysseek($in, 0, SEEK_SET))) { err($env, "error seeking temporary file: $!"); return; |