* [PATCH 0/5] watch: various bugfixes and fairness improvements
@ 2017-06-26 3:15 5% Eric Wong
2017-06-26 3:15 7% ` [PATCH 1/5] watch: ensure HUP causes the scanner to be reloaded Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2017-06-26 3:15 UTC (permalink / raw)
To: meta
A fairly large reworking of "public-inbox-watch" to improve
fairness when processing large directory scans. There are
also some minor bugfixes for signal handling.
Eric Wong (5):
watch: ensure HUP causes the scanner to be reloaded
spamc: retry on EINTR
watch: improve fairness during full rescans
watch: use "self-inotify-tempfile trick" for quit
watch: commit changes to fast-import sooner
lib/PublicInbox/Spamcheck/Spamc.pm | 6 +-
lib/PublicInbox/WatchMaildir.pm | 110 +++++++++++++++++++++++++++++--------
script/public-inbox-watch | 9 ++-
t/watch_maildir.t | 12 ++--
4 files changed, 105 insertions(+), 32 deletions(-)
--
EW
^ permalink raw reply [relevance 5%]
* [PATCH 1/5] watch: ensure HUP causes the scanner to be reloaded
2017-06-26 3:15 5% [PATCH 0/5] watch: various bugfixes and fairness improvements Eric Wong
@ 2017-06-26 3:15 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2017-06-26 3:15 UTC (permalink / raw)
To: meta
Otherwise the old watcher may run indefinitely
---
lib/PublicInbox/WatchMaildir.pm | 4 +++-
script/public-inbox-watch | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index c15e138..f81a917 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -179,6 +179,8 @@ sub _try_path {
$im->add($mime, $self->{spamcheck});
}
+sub quit { $_[0]->{quit} = 1 }
+
sub watch {
my ($self) = @_;
my $cb = sub { _try_fsn_paths($self, \@_) };
@@ -188,7 +190,7 @@ sub watch {
# in the future...
require Filesys::Notify::Simple;
my $watcher = Filesys::Notify::Simple->new($mdir);
- $watcher->wait($cb) while (1);
+ $watcher->wait($cb) until ($self->{quit});
}
sub scan {
diff --git a/script/public-inbox-watch b/script/public-inbox-watch
index bb65592..a72180c 100755
--- a/script/public-inbox-watch
+++ b/script/public-inbox-watch
@@ -8,6 +8,7 @@ use PublicInbox::Config;
my ($config, $watch_md);
my $reload = sub {
$config = PublicInbox::Config->new;
+ $watch_md->quit if $watch_md;
$watch_md = PublicInbox::WatchMaildir->new($config);
};
$reload->();
@@ -17,5 +18,5 @@ if ($watch_md) {
$SIG{USR1} = $scan;
$SIG{ALRM} = sub { $SIG{ALRM} = 'DEFAULT'; $scan->() };
alarm(1);
- $watch_md->watch;
+ $watch_md->watch while ($watch_md);
}
--
EW
^ permalink raw reply related [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2017-06-26 3:15 5% [PATCH 0/5] watch: various bugfixes and fairness improvements Eric Wong
2017-06-26 3:15 7% ` [PATCH 1/5] watch: ensure HUP causes the scanner to be reloaded Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).