about summary refs log tree commit homepage
path: root/lib/PublicInbox/IMAPdeflate.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:29 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commitc4dd2b484bbb20f2be0d7bc4a0ae0e91df635b4a (patch)
treedf1069a4469010e1a1a8ca717a093357a563cdb7 /lib/PublicInbox/IMAPdeflate.pm
parentafa44e1ddf1b9402caba5c7dc3c8e0f86194df86 (diff)
downloadpublic-inbox-c4dd2b484bbb20f2be0d7bc4a0ae0e91df635b4a.tar.gz
Since IMAP yields control to GitAsyncCat, IMAP->event_step may
be invoked with {long_cb} still active.  We must be sure to
bail out of IMAP->event_step if that happens and continue to let
GitAsyncCat drive IMAP.

This also improves fairness by never processing more than one
request per ->event_step.
Diffstat (limited to 'lib/PublicInbox/IMAPdeflate.pm')
-rw-r--r--lib/PublicInbox/IMAPdeflate.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/PublicInbox/IMAPdeflate.pm b/lib/PublicInbox/IMAPdeflate.pm
index 67c9a973..42daa6cf 100644
--- a/lib/PublicInbox/IMAPdeflate.pm
+++ b/lib/PublicInbox/IMAPdeflate.pm
@@ -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);