]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IMAPdeflate.pm
imap: fix pipelining with async git
[public-inbox.git] / lib / PublicInbox / IMAPdeflate.pm
index 67c9a9738d54836fe12edf7a5911983945c41ba4..42daa6cffaaa37f75b581e4665ebfece65cf8a77 100644 (file)
@@ -59,6 +59,16 @@ sub do_read ($$$$) {
        $doff = length($dbuf);
        my $r = PublicInbox::DS::do_read($self, \$dbuf, $len, $doff) or return;
 
+       # Workaround inflate bug appending to OOK scalars:
+       # <https://rt.cpan.org/Ticket/Display.html?id=132734>
+       # We only have $off if the client is pipelining, and pipelining
+       # is where our substr() OOK optimization in event_step makes sense.
+       if ($off) {
+               my $copy = $$rbuf;
+               undef $$rbuf;
+               $$rbuf = $copy;
+       }
+
        # assert(length($$rbuf) == $off) as far as NNTP.pm is concerned
        # -ConsumeInput is true, so $dbuf is automatically emptied
        my $err = $zin->inflate($dbuf, $rbuf);