]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IMAP.pm
git_async_cat: remove circular reference
[public-inbox.git] / lib / PublicInbox / IMAP.pm
index 64b57a3ef69ada62d5cfbf6b57986d7fbc22d017..0a6993c64c474526949bc3eac0590dc90dae18d8 100644 (file)
@@ -166,7 +166,7 @@ sub cmd_login ($$$$) {
 
 sub cmd_close ($$) {
        my ($self, $tag) = @_;
-       delete $self->{uid_base};
+       delete @$self{qw(uid_base uo2m)};
        delete $self->{ibx} ? "$tag OK Close done\r\n"
                                : "$tag BAD No mailbox\r\n";
 }
@@ -220,7 +220,7 @@ sub uo2m_hibernate ($) {
 
 sub uo2m_last_uid ($) {
        my ($self) = @_;
-       my $uo2m = $self->{uo2m} or die 'BUG: uo2m_last_uid w/o {uo2m}';
+       defined(my $uo2m = $self->{uo2m}) or die 'BUG: uo2m_last_uid w/o {uo2m}';
        (ref($uo2m) ? @$uo2m : (length($uo2m) >> 1)) + $self->{uid_base};
 }
 
@@ -415,6 +415,7 @@ sub cmd_examine ($$$) {
        my ($ibx, $exists, $uidnext, $base) = inbox_lookup($self, $mailbox);
        return "$tag NO Mailbox doesn't exist: $mailbox\r\n" if !$ibx;
        $self->{uid_base} = $base;
+       delete $self->{uo2m};
 
        # XXX: do we need this? RFC 5162/7162
        my $ret = $self->{ibx} ? "* OK [CLOSED] previous closed\r\n" : '';
@@ -1171,16 +1172,13 @@ sub refill_xap ($$$$) {
        my $srch = $self->{ibx}->search;
        my $opt = { mset => 2, limit => 1000 };
        my $nshard = $srch->{nshard} // 1;
-       while (1) {
-               my $mset = $srch->query("$q uid:$beg..$end", $opt);
-               @$uids = map { mdocid($nshard, $_) } $mset->items;
-               if (@$uids) {
-                       $range_info->[0] = $uids->[-1] + 1; # update $beg
-                       return;
-               } else { # all done
-                       return 0;
-               }
+       my $mset = $srch->query("$q uid:$beg..$end", $opt);
+       @$uids = map { mdocid($nshard, $_) } $mset->items;
+       if (@$uids) {
+               $range_info->[0] = $uids->[-1] + 1; # update $beg
+               return; # possibly more
        }
+       0; # all done
 }
 
 sub search_xap_range { # long_response
@@ -1296,7 +1294,7 @@ sub long_step {
        } elsif ($more) { # $self->{wbuf}:
                $self->update_idle_time;
 
-               # control passed to $more may be a GitAsyncCat object
+               # control passed to git_async_cat if $more == \undef
                requeue_once($self) if !ref($more);
        } else { # all done!
                delete $self->{long_cb};