summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
50ac810)
We can amortize the cost of NEWGROUPS time filtering using the
long_response API. This lets us handle hundreds/thousands of
inboxes without monopolizing the event loop for this command.
Further speedup is possible using MiscSearch, but that requires
not-yet-done indexing changes to MiscIdx.
more($self, "$ng->{newsgroup} $max $min n");
}
more($self, "$ng->{newsgroup} $max $min n");
}
+sub newgroups_i {
+ my ($self, $ts, $i, $groupnames) = @_;
+ my $end = $$i + 100;
+ my $groups = $self->{nntpd}->{pi_config}->{-by_newsgroup};
+ while ($$i < $end) {
+ my $ngname = $groupnames->[$$i++] // return;
+ my $ibx = $groups->{$ngname} or next; # expired on reload
+ next unless (eval { $ibx->uidvalidity } // 0) > $ts;
+ group_line($self, $ibx);
+ }
+ 1;
+}
+
sub cmd_newgroups ($$$;$$) {
my ($self, $date, $time, $gmt, $dists) = @_;
my $ts = eval { parse_time($date, $time, $gmt) };
sub cmd_newgroups ($$$;$$) {
my ($self, $date, $time, $gmt, $dists) = @_;
my $ts = eval { parse_time($date, $time, $gmt) };
# TODO dists
more($self, '231 list of new newsgroups follows');
# TODO dists
more($self, '231 list of new newsgroups follows');
- foreach my $ng (@{$self->{nntpd}->{grouplist}}) {
- my $c = eval { $ng->uidvalidity } // 0;
- next unless $c > $ts;
- group_line($self, $ng);
- }
- '.'
+ long_response($self, \&newgroups_i, $ts, \(my $i = 0),
+ $self->{nntpd}->{groupnames});
groups => {},
err => \*STDERR,
out => \*STDOUT,
groups => {},
err => \*STDERR,
out => \*STDOUT,
pi_config => $pi_config,
servername => $name,
greet => \"201 $name ready - post via email\r\n",
pi_config => $pi_config,
servername => $name,
greet => \"201 $name ready - post via email\r\n",
delete $groups->{$ngname};
}
});
delete $groups->{$ngname};
}
});
- my @names = sort(keys %$groups);
- $self->{grouplist} = [ map { $groups->{$_} } @names ];
- $self->{groupnames} = \@names;
+ $self->{groupnames} = [ sort(keys %$groups) ];
$self->{pi_config} = $pi_config;
# this will destroy old groups that got deleted
$self->{groups} = $groups;
$self->{pi_config} = $pi_config;
# this will destroy old groups that got deleted
$self->{groups} = $groups;
my $hdr = $mime->header_obj;
my $mock_self = {
nntpd => {
my $hdr = $mime->header_obj;
my $mock_self = {
nntpd => {
servername => 'example.com',
pi_config => bless {}, 'PublicInbox::Config',
},
servername => 'example.com',
pi_config => bless {}, 'PublicInbox::Config',
},