my $valid_range = '[0-9]+|[0-9]+:[0-9]+|[0-9]+:\*';
$valid_range = qr/\A(?:$valid_range)(?:,(?:$valid_range))*\z/;
-# RFC 3501 5.4. Autologout Timer needs to be >= 30min
-$PublicInbox::DS::EXPTIME = 60 * 30;
-
sub greet ($) {
my ($self) = @_;
my $capa = capa($self);
} else {
greet($self);
}
- $self->update_idle_time;
$self;
}
}
}
-# called every X minute(s) or so by PublicInbox::DS::later
-my $IDLERS = {};
-my $idle_timer;
+# called every minute or so by PublicInbox::DS::later
+my $IDLERS; # fileno($obj->{sock}) => PublicInbox::IMAP
sub idle_tick_all {
my $old = $IDLERS;
- $IDLERS = {};
+ $IDLERS = undef;
for my $i (values %$old) {
next if ($i->{wbuf} || !exists($i->{-idle_tag}));
- $i->update_idle_time or next;
$IDLERS->{fileno($i->{sock})} = $i;
$i->write(\"* OK Still here\r\n");
}
- $idle_timer = scalar keys %$IDLERS ?
- PublicInbox::DS::later(\&idle_tick_all) : undef;
+ $IDLERS and
+ PublicInbox::DS::add_uniq_timer('idle', 60, \&idle_tick_all);
}
sub cmd_idle ($$) {
$ibx->subscribe_unlock($fd, $self);
$self->{imapd}->idler_start;
}
- $idle_timer //= PublicInbox::DS::later(\&idle_tick_all);
+ PublicInbox::DS::add_uniq_timer('idle', 60, \&idle_tick_all);
$IDLERS->{$fd} = $self;
\"+ idling\r\n"
}
push @created, $sub_mailbox;
}
return unless @created;
- my $l = $imapd->{inboxlist} or return;
+ my $l = $imapd->{mailboxlist} or return;
push @$l, map { qq[* LIST (\\HasNoChildren) "." $_\r\n] } @created;
}
die "BUG: unexpected dummy mailbox: $mailbox\n";
$uid_base = $1 * UID_SLICE;
- # ->num_highwater caches for writers, so use ->meta_accessor
- $uidmax = $ibx->mm->meta_accessor('num_highwater') // 0;
+ $uidmax = $ibx->mm->num_highwater // 0;
if ($examine) {
$self->{uid_base} = $uid_base;
$self->{ibx} = $ibx;
my %patmap = ('*' => '.*', '%' => '[^\.]*');
sub cmd_list ($$$$) {
my ($self, $tag, $refname, $wildcard) = @_;
- my $l = $self->{imapd}->{inboxlist};
+ my $l = $self->{imapd}->{mailboxlist};
if ($refname eq '' && $wildcard eq '') {
# request for hierarchy delimiter
$l = [ qq[* LIST (\\Noselect) "." ""\r\n] ];
# prepares an index for BODY[$SECTION_IDX] fetches
sub eml_body_idx ($$) {
my ($eml, $section_idx) = @_;
- my $idx = $eml->{imap_all_parts} //= do {
+ my $idx = $eml->{imap_all_parts} // do {
my $all = {};
$eml->each_part(\&eml_index_offs_i, $all, 0, 1);
# top-level of multipart, BODY[0] not allowed (nz-number)
delete $all->{0};
- $all;
+ $eml->{imap_all_parts} = $all;
};
$idx->{$section_idx};
}
out($self, " deferred[$fd] aborted - %0.6f", $elapsed);
$self->close;
} elsif ($more) { # $self->{wbuf}:
- $self->update_idle_time;
-
# control passed to ibx_async_cat if $more == \undef
requeue_once($self) if !ref($more);
} else { # all done!
return unless $self->flush_write && $self->{sock} && !$self->{long_cb};
- $self->update_idle_time;
# only read more requests if we've drained the write buffer,
# otherwise we can be buffering infinitely w/o backpressure
return $self->close if $r < 0;
$self->rbuf_idle($rbuf);
- $self->update_idle_time;
# maybe there's more pipelined data, or we'll have
# to register it for socket-readiness notifications
undef;
}
-# for graceful shutdown in PublicInbox::Daemon:
-sub busy {
- my ($self, $now) = @_;
+sub busy { # for graceful shutdown in PublicInbox::Daemon:
+ my ($self) = @_;
if (defined($self->{-idle_tag})) {
$self->write(\"* BYE server shutting down\r\n");
return; # not busy anymore
}
- ($self->{rbuf} || $self->{wbuf} || $self->not_idle_long($now));
+ defined($self->{rbuf}) || defined($self->{wbuf}) ||
+ !$self->write(\"* BYE server shutting down\r\n");
}
sub close {