* [PATCH 1/4] t/inbox_idle: delay for low-res FS w/o inotify||kqueue
2024-11-11 21:56 [PATCH 0/4] another round of small fixes Eric Wong
@ 2024-11-11 21:56 ` Eric Wong
2024-11-11 21:56 ` [PATCH 2/4] t/spawn: increase timeout for slow systems Eric Wong
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2024-11-11 21:56 UTC (permalink / raw)
To: meta
On systems without inotify||kqueue, changes are unreliably
detected on filesystems with low-resolution timestamps. The
FakeInotify emulation can't detect changes properly in all
cases. While this remains a problem for real-world use cases,
systems w/o inotify or IO::KQueue are probably rare, so we'll
just change this test case to accomodate old FSes which lack
high resolution timestamps.
Keep in mind that mounting an old FS on a modern kernel doesn't
automatically give it high-resolution timestamps. I discovered
this problem because I still use an ancient ext3 FS created
decades ago on a modern kernel :x
---
t/inbox_idle.t | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/t/inbox_idle.t b/t/inbox_idle.t
index 0ccffab7..94f3845c 100644
--- a/t/inbox_idle.t
+++ b/t/inbox_idle.t
@@ -9,6 +9,11 @@ require PublicInbox::SearchIdx;
use_ok 'PublicInbox::InboxIdle';
my ($tmpdir, $for_destroy) = tmpdir();
+# for non-inotify|kqueue systems w/ low-res FS timestamps
+# This only makes the test work, but either high-res FS timestamps
+# or inotify or kqueue support needs to be added to your system.
+my $poll_delay = 1;
+
for my $V (1, 2) {
my $inboxdir = "$tmpdir/$V";
my $ibx = create_inbox "idle$V", tmpdir => $inboxdir, version => $V,
@@ -35,16 +40,21 @@ EOF
my $ii = PublicInbox::InboxIdle->new($pi_cfg);
ok($ii, 'InboxIdle created');
SKIP: {
- skip('inotify or kqueue missing', 1) unless $ii->{sock};
+ $ii->{sock} or skip
+'inotify or kqueue missing, expect real-world breakage on low-res FSes', 1;
ok(fileno($ii->{sock}) >= 0, 'fileno() gave valid FD');
+ $poll_delay = 0;
}
my $im = $ibx->importer(0);
ok($im->add(eml_load('t/utf8.eml')), "$V added");
+ tick $poll_delay if $poll_delay;
$im->done;
$ii->event_step;
- is(scalar @{$obj->{called}}, 1, 'called on unlock');
+ is(scalar @{$obj->{called}}, 1, 'called on unlock') or
+ diag explain($obj);
$pi_cfg->each_inbox(sub { shift->unsubscribe_unlock($ident) });
ok($im->add(eml_load('t/data/0001.patch')), "$V added #2");
+ tick $poll_delay if $poll_delay;
$im->done;
$ii->event_step;
is(scalar @{$obj->{called}}, 1, 'not called when unsubbed');
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] t/spawn: increase timeout for slow systems
2024-11-11 21:56 [PATCH 0/4] another round of small fixes Eric Wong
2024-11-11 21:56 ` [PATCH 1/4] t/inbox_idle: delay for low-res FS w/o inotify||kqueue Eric Wong
@ 2024-11-11 21:56 ` Eric Wong
2024-11-11 21:56 ` [PATCH 3/4] import: avoid uninitialized comparison on failures Eric Wong
2024-11-11 21:56 ` [PATCH 4/4] view: avoid uninitialized var from diff query textarea Eric Wong
3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2024-11-11 21:56 UTC (permalink / raw)
To: meta
Smetimes the SIGXCPU handler doesn't fire in time on an
overloaded VPS, so hopefully increasing the timeout is now
enough. The $rset allocation and bitset is now moved before
the spawn to avoid measuring any possible overhead from the
scalar creation.
---
t/spawn.t | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/t/spawn.t b/t/spawn.t
index 45517852..36f4ed2e 100644
--- a/t/spawn.t
+++ b/t/spawn.t
@@ -228,11 +228,10 @@ EOM
pipe(my($r, $w)) or die "pipe: $!";
my $fd = fileno($w);
my $opt = { RLIMIT_CPU => [ 1, 9 ], RLIMIT_CORE => [ 0, 0 ], 1 => $fd };
+ vec(my $rset = '', fileno($r), 1) = 1;
my $pid = spawn($cmd, undef, $opt);
close $w or die "close(w): $!";
- my $rset = '';
- vec($rset, fileno($r), 1) = 1;
- ok(select($rset, undef, undef, 5), 'child died before timeout');
+ ok(select($rset, undef, undef, 8), 'child died before timeout');
is(waitpid($pid, 0), $pid, 'XCPU child process reaped');
my $line;
like($line = readline($r), qr/SIGXCPU/, 'SIGXCPU handled') or
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] import: avoid uninitialized comparison on failures
2024-11-11 21:56 [PATCH 0/4] another round of small fixes Eric Wong
2024-11-11 21:56 ` [PATCH 1/4] t/inbox_idle: delay for low-res FS w/o inotify||kqueue Eric Wong
2024-11-11 21:56 ` [PATCH 2/4] t/spawn: increase timeout for slow systems Eric Wong
@ 2024-11-11 21:56 ` Eric Wong
2024-11-11 21:56 ` [PATCH 4/4] view: avoid uninitialized var from diff query textarea Eric Wong
3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2024-11-11 21:56 UTC (permalink / raw)
To: meta
readline may return undef when fast-import fails (as triggered
by t/lei-store-fail.t). Ensure we give a more informative error
message in the syslog when this happens. Arguably, having this
in the syslog when a client is connected via terminal is probably
not great, but perhaps unavoidable...
---
lib/PublicInbox/Import.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 2e193d46..ae46c5f4 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -152,8 +152,8 @@ sub progress {
my ($self, $msg) = @_;
my $io = $self->{io} or return;
print $io "progress $msg\n" or wfail;
- readline($io) eq "progress $msg\n" or die
- "progress $msg not received\n";
+ my $res = <$io> // die "EOF from fast-import progress $msg: $!";
+ $res eq "progress $msg\n" or die "BUG: `$res' != `progress $msg'";
undef;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] view: avoid uninitialized var from diff query textarea
2024-11-11 21:56 [PATCH 0/4] another round of small fixes Eric Wong
` (2 preceding siblings ...)
2024-11-11 21:56 ` [PATCH 3/4] import: avoid uninitialized comparison on failures Eric Wong
@ 2024-11-11 21:56 ` Eric Wong
3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2024-11-11 21:56 UTC (permalink / raw)
To: meta
Rare commits without titles and emails without a Subject: header
should not litter stderr or syslog with uninitialized variable
warnings.
---
lib/PublicInbox/View.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 275258e3..7ca85a85 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -849,7 +849,7 @@ sub thread_skel ($$$) {
sub dfqry_text ($$) {
my ($ctx, $subj) = @_;
my $qry_dfblob = delete $ctx->{-qry_dfblob} or return (undef);
- my @bs = split /["\x{201c}\x{201d}]+/, $subj;
+ my @bs = split /["\x{201c}\x{201d}]+/, $subj // '';
my $q = join ' ', (@bs ? ('(') : ()), map {
chop if length > 7; # include 1 abbrev "older" patches
"dfblob:$_";
^ permalink raw reply related [flat|nested] 5+ messages in thread