]> Sergey Matveev's repositories - public-inbox.git/commitdiff
Merge remote-tracking branch 'origin/nntp-tls'
authorEric Wong <e@80x24.org>
Wed, 26 Jun 2019 06:36:27 +0000 (06:36 +0000)
committerEric Wong <e@80x24.org>
Wed, 26 Jun 2019 06:36:27 +0000 (06:36 +0000)
* origin/nntp-tls: (59 commits)
  ds: ->write must not clobber empty wbuf array
  Makefile: skip DSKQXS in global syntax check
  ds: reduce overhead of tempfile creation
  Revert "ci: require IO::KQueue on FreeBSD, for now"
  ds: reimplement IO::Poll support to look like epoll
  ds: split out IO::KQueue-specific code
  daemon: use FreeBSD accept filters on non-NNTP
  daemon: set TCP_DEFER_ACCEPT on everything but NNTP
  nntp: send greeting immediately for plain sockets
  ci: require IO::KQueue on FreeBSD, for now
  nntp: lazily allocate and stash rbuf
  ds: flush_write runs ->write callbacks even if closed
  nntp: simplify long response logic and fix nesting
  ds: always use EV_ADD with EV_SET
  nntp: reduce allocations for greeting
  ds: allow ->write callbacks to syswrite directly
  daemon: use SSL_MODE_RELEASE_BUFFERS
  t/nntpd-tls: slow client connection test
  nntp: call SSL_shutdown in normal cases
  ds|nntp: use CORE::close on socket
  ...

lib/PublicInbox/Msgmap.pm
lib/PublicInbox/SearchView.pm
lib/PublicInbox/WwwListing.pm
t/msgmap.t
t/v2writable.t
t/www_listing.t

index 0035c9e3dc1ad8ff5bad1d3201ab06ecf9105032..5a89b85a51e297660291f0c4e5477bd2865608da 100644 (file)
@@ -126,9 +126,9 @@ sub mid_insert {
        my ($self, $mid) = @_;
        my $dbh = $self->{dbh};
        my $sth = $dbh->prepare_cached(<<'');
-INSERT OR IGNORE INTO msgmap (mid) VALUES (?)
+INSERT INTO msgmap (mid) VALUES (?)
 
-       return if $sth->execute($mid) == 0;
+       return unless eval { $sth->execute($mid) };
        my $num = $dbh->last_insert_id(undef, undef, 'msgmap', 'num');
        $self->num_highwater($num) if defined($num);
        $num;
index 6f07279bd72c21d05aeb3527fc0af02b7785bcdc..a8b66dda9004ad6cca983bff668f9ab06b7ef181 100644 (file)
@@ -15,6 +15,7 @@ use PublicInbox::MIME;
 require PublicInbox::Git;
 require PublicInbox::SearchThread;
 our $LIM = 200;
+my %rmap_inc;
 
 sub noop {}
 
@@ -138,10 +139,27 @@ sub mset_summary {
        *noop;
 }
 
+# shorten "/full/path/to/Foo/Bar.pm" to "Foo/Bar.pm" so error
+# messages don't reveal FS layout info in case people use non-standard
+# installation paths
+sub path2inc ($) {
+       my $full = $_[0];
+       if (my $short = $rmap_inc{$full}) {
+               return $short;
+       } elsif (!scalar(keys %rmap_inc) && -e $full) {
+               %rmap_inc = map {; "$INC{$_}" => $_ } keys %INC;
+               # fall back to basename as last resort
+               $rmap_inc{$full} // (split('/', $full))[-1];
+       } else {
+               $full;
+       }
+}
+
 sub err_txt {
        my ($ctx, $err) = @_;
        my $u = $ctx->{-inbox}->base_url($ctx->{env}) . '_/text/help/';
        $err =~ s/^\s*Exception:\s*//; # bad word to show users :P
+       $err =~ s!(\S+)!path2inc($1)!sge;
        $err = ascii_html($err);
        "\nBad query: <b>$err</b>\n" .
                qq{See <a\nhref="$u">$u</a> for help on using search};
index e052bbffa938ec04f0946c09b109b7df903855e3..1d4029f047ed35a738ed7c75854d374f23ba93c2 100644 (file)
@@ -138,8 +138,8 @@ sub fingerprint ($) {
        $dig->hexdigest;
 }
 
-sub manifest_add ($$;$) {
-       my ($manifest, $ibx, $epoch) = @_;
+sub manifest_add ($$;$$) {
+       my ($manifest, $ibx, $epoch, $default_desc) = @_;
        my $url_path = "/$ibx->{name}";
        my $git_dir = $ibx->{mainrepo};
        if (defined $epoch) {
@@ -155,6 +155,13 @@ sub manifest_add ($$;$) {
        $owner = undef if $owner eq '';
        $desc = 'Unnamed repository' if $desc eq '';
 
+       # templates/hooks--update.sample and git-multimail in git.git
+       # only match "Unnamed repository", not the full contents of
+       # templates/this--description in git.git
+       if ($desc =~ /\AUnnamed repository/) {
+               $desc = "$default_desc [epoch $epoch]" if defined($epoch);
+       }
+
        my $reference;
        chomp(my $alt = try_cat("$git_dir/objects/info/alternates"));
        if ($alt) {
@@ -191,8 +198,9 @@ sub js ($$) {
        my $manifest = { -abs2urlpath => {}, -mtime => 0 };
        for my $ibx (@$list) {
                if (defined(my $max = $ibx->max_git_epoch)) {
+                       my $desc = $ibx->description;
                        for my $epoch (0..$max) {
-                               manifest_add($manifest, $ibx, $epoch);
+                               manifest_add($manifest, $ibx, $epoch, $desc);
                        }
                } else {
                        manifest_add($manifest, $ibx);
index 4dddd0a81852b22c60601b1965d1e7b11224897c..20985ce8cb56be0b9d280660a75eaca6ac27739f 100644 (file)
@@ -30,6 +30,9 @@ $@ = undef;
 my $ret = $d->mid_insert('a@b');
 is($ret, undef, 'duplicate mid_insert in undef result');
 is($d->num_for('a@b'), $mid2num{'a@b'}, 'existing number not clobbered');
+my $next = (sort(keys %num2mid))[-1];
+is($d->mid_insert('ok@unique'), $next + 1,
+       'got expected num after failing mid_insert');
 
 foreach my $n (keys %num2mid) {
        is($d->mid_for($n), $num2mid{$n}, "num:$n maps correctly");
index 88df2d64a30a065dd057f36f6568b8644693f58f..8f32fbe5d9c42e9abfd31e33ce70200c46ca03b6 100644 (file)
@@ -118,6 +118,8 @@ if ('ensure git configs are correct') {
        $mime->header_set('References', '<zz-mid@b>');
        ok($im->add($mime), 'message with multiple Message-ID');
        $im->done;
+       my ($total, undef) = $ibx->over->recent;
+       is($ibx->mm->num_highwater, $total, 'got expected highwater value');
        my $srch = $ibx->search;
        my $mset1 = $srch->reopen->query('m:abcde@1', { mset => 1 });
        is($mset1->size, 1, 'message found by first MID');
index d82a4a4a581345425d06a03bdfbc786a8c44c2c5..e5b797db7f9582c954702ac69d008fa4c453ae8a 100644 (file)
@@ -55,7 +55,12 @@ sub tiny_test {
                $res->{headers}->{'last-modified'},
                'modified field and Last-Modified header match');
 
-       ok($manifest->{'/v2/git/0.git'}, 'v2 epoch appeared');
+       ok(my $v2epoch0 = $manifest->{'/v2/git/0.git'}, 'v2 epoch 0 appeared');
+       like($v2epoch0->{description}, qr/ \[epoch 0\]\z/,
+               'epoch 0 in description');
+       ok(my $v2epoch1 = $manifest->{'/v2/git/1.git'}, 'v2 epoch 1 appeared');
+       like($v2epoch1->{description}, qr/ \[epoch 1\]\z/,
+               'epoch 1 in description');
 }
 
 my $pid;