* [PATCH 4/5] watch: use "self-inotify-tempfile trick" for quit
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
This should be more reliable and safer as it'll ensure
existing fast-import instances are shut down properly.
---
lib/PublicInbox/WatchMaildir.pm | 12 ++++++++++--
script/public-inbox-watch | 4 ++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index fc42ec4..b867edc 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -200,7 +200,7 @@ sub _try_path {
$im->add($mime, $self->{spamcheck});
}
-sub quit { $_[0]->{quit} = 1 }
+sub quit { trigger_scan($_[0], 'quit') }
sub watch {
my ($self) = @_;
@@ -214,7 +214,7 @@ sub watch {
# in the future...
require Filesys::Notify::Simple;
my $fsn = Filesys::Notify::Simple->new([@{$self->{mdir}}, $scandir]);
- $fsn->wait($cb) until ($self->{quit});
+ $fsn->wait($cb) until $self->{quit};
}
sub trigger_scan {
@@ -226,6 +226,14 @@ sub trigger_scan {
sub scan {
my ($self, $path) = @_;
+ if ($path =~ /quit\z/) {
+ %{$self->{opendirs}} = ();
+ _done_for_now($self);
+ $self->{quit} = 1;
+ return;
+ }
+ # else: $path =~ /(cont|full)\z/
+ return if $self->{quit};
my $max = 10;
my $opendirs = $self->{opendirs};
my @dirnames = keys %$opendirs;
diff --git a/script/public-inbox-watch b/script/public-inbox-watch
index 51f1baa..0d1cd83 100755
--- a/script/public-inbox-watch
+++ b/script/public-inbox-watch
@@ -17,6 +17,10 @@ if ($watch_md) {
$SIG{HUP} = $reload;
$SIG{USR1} = $scan;
$SIG{ALRM} = sub { $SIG{ALRM} = 'DEFAULT'; $scan->() };
+ $SIG{QUIT} = $SIG{TERM} = $SIG{INT} = sub {
+ $watch_md->quit if $watch_md;
+ $watch_md = undef;
+ };
alarm(1);
$watch_md->watch while ($watch_md);
}
--
EW
^ permalink raw reply related [relevance 7%]
* [PATCH 0/5] watch: various bugfixes and fairness improvements
@ 2017-06-26 3:15 5% Eric Wong
2017-06-26 3:15 7% ` [PATCH 4/5] watch: use "self-inotify-tempfile trick" for quit 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%]
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 4/5] watch: use "self-inotify-tempfile trick" for quit 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).