summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0dceebd)
id_batch had a an overly complicated interface, replace it
with id_batch which is simpler and takes advantage of
selectcol_arrayref in DBI. This allows simplification of
callers and the diffstat agrees with me.
return sub { need_gzip(@_) } if $@;
if ($query eq '') {
my $prev = 0;
return sub { need_gzip(@_) } if $@;
if ($query eq '') {
my $prev = 0;
- my $msgs = [];
- my $cb = sub {
- $ctx->{-inbox}->mm->id_batch($prev, sub {
- $msgs = $_[0];
- });
- $prev = $msgs->[-1] if @$msgs;
- $msgs;
- };
+ my $cb = sub { $ctx->{-inbox}->mm->ids_after(\$prev) };
return PublicInbox::MboxGz->response($ctx, $cb, 'all');
}
my $opts = { offset => 0 };
return PublicInbox::MboxGz->response($ctx, $cb, 'all');
}
my $opts = { offset => 0 };
do {
# work on existing result set
while (defined(my $smsg = shift @$msgs)) {
do {
# work on existing result set
while (defined(my $smsg = shift @$msgs)) {
- # id_batch may return integers
+ # ids_after may return integers
ref($smsg) or
$smsg = $ctx->{srch}->{over_ro}->get_art($smsg);
ref($smsg) or
$smsg = $ctx->{srch}->{over_ro}->get_art($smsg);
-sub id_batch {
- my ($self, $num, $cb) = @_;
- my $dbh = $self->{dbh};
- my $sth = $dbh->prepare('SELECT num FROM msgmap WHERE num > ? '.
- 'ORDER BY num ASC LIMIT 1000');
- $sth->execute($num);
- my $ary = $sth->fetchall_arrayref;
- @$ary = map { $_->[0] } @$ary;
- my $nr = scalar @$ary;
- $cb->($ary) if $nr;
- $nr;
+sub ids_after {
+ my ($self, $num) = @_;
+ my $ids = $self->{dbh}->selectcol_arrayref(<<'', undef, $$num);
+SELECT num FROM msgmap WHERE num > ?
+ORDER BY num ASC LIMIT 1000
+
+ $$num = $ids->[-1] if @$ids;
+ $ids;
}
# only used for mapping external serial numbers (e.g. articles from gmane)
}
# only used for mapping external serial numbers (e.g. articles from gmane)
qw(:bytes :lines Xref To Cc)) . "\r\n";
# disable commands with easy DoS potential:
qw(:bytes :lines Xref To Cc)) . "\r\n";
# disable commands with easy DoS potential:
-# LISTGROUP could get pretty bad, too...
my %DISABLED; # = map { $_ => 1 } qw(xover list_overview_fmt newnews xhdr);
my $EXPMAP; # fd -> [ idle_time, $self ]
my %DISABLED; # = map { $_ => 1 } qw(xover list_overview_fmt newnews xhdr);
my $EXPMAP; # fd -> [ idle_time, $self ]
}
$self->{ng} or return '412 no newsgroup selected';
}
$self->{ng} or return '412 no newsgroup selected';
long_response($self, 0, long_response_limit, sub {
my ($i) = @_;
long_response($self, 0, long_response_limit, sub {
my ($i) = @_;
- my $nr = $self->{ng}->mm->id_batch($$i, sub {
- my ($ary) = @_;
- more($self, join("\r\n", @$ary));
- });
-
- # -1 to adjust for implicit increment in long_response
- $$i = $nr ? $$i + $nr - 1 : long_response_limit;
+ my $ary = $self->{ng}->mm->ids_after(\$n);
+ scalar @$ary or return ($$i = long_response_limit);
+ more($self, join("\r\n", @$ary));
my $list = $n->list;
is_deeply($list, { $group => [ qw(1 1 n) ] }, 'LIST works');
is_deeply([$n->group($group)], [ qw(0 1 1), $group ], 'GROUP works');
my $list = $n->list;
is_deeply($list, { $group => [ qw(1 1 n) ] }, 'LIST works');
is_deeply([$n->group($group)], [ qw(0 1 1), $group ], 'GROUP works');
+ is_deeply($n->listgroup($group), [1], 'listgroup OK');
%opts = (
PeerAddr => $host_port,
%opts = (
PeerAddr => $host_port,
is($nn{$mid}++, 0, "MID is unique in NEWNEWS");
}
is_deeply([sort keys %nn], [sort keys %uniq]);
is($nn{$mid}++, 0, "MID is unique in NEWNEWS");
}
is_deeply([sort keys %nn], [sort keys %uniq]);
+
+ my %lg;
+ foreach my $num (@{$n->listgroup($group)}) {
+ is($lg{$num}++, 0, "num is unique in LISTGROUP");
+ }
+ is_deeply([sort keys %lg], [sort keys %$x],
+ 'XOVER and LISTGROUPS return the same article numbers');
};
{
local $ENV{NPROC} = 2;
};
{
local $ENV{NPROC} = 2;