]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/DS.pm
ds: tmpio: avoid Perl target cache
[public-inbox.git] / lib / PublicInbox / DS.pm
index debb777a27e88ca675f703b396b1482138046b02..9cca02d7ffe99c5d32446c213c1817d53e0a7e80 100644 (file)
@@ -494,16 +494,15 @@ sub drop {
     $self->close;
 }
 
-# n.b.: use ->write/->read for this buffer to allow compatibility with
-# PerlIO::mmap or PerlIO::scalar if needed
 sub tmpio ($$$) {
        my ($self, $bref, $off) = @_;
        my $fh = tmpfile('wbuf', $self->{sock}, O_APPEND) or
                return drop($self, "tmpfile $!");
        $fh->autoflush(1);
        my $len = length($$bref) - $off;
-       print $fh substr($$bref, $off, $len) or
+       my $n = syswrite($fh, $$bref, $len, $off) //
                return drop($self, "write ($len): $!");
+       $n == $len or return drop($self, "wrote $n < $len bytes");
        [ $fh, 0 ] # [1] = offset, [2] = length, not set by us
 }