* [PATCH 0/9] big mda filter changes
@ 2016-06-15 0:37 7% Eric Wong
2016-06-15 0:37 6% ` [PATCH 3/9] learn: remove IPC::Run dependency Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2016-06-15 0:37 UTC (permalink / raw)
To: meta
Eric Wong (9):
drop dependency on File::Path::Expand
t/feed.t: make IPC::Run usage optional
learn: remove IPC::Run dependency
t/mda.t: remove senseless use of Email::Filter
t/mda: use only Maildir for testing
mda: precheck no longer depends on Email::Filter
filter: begin work on a new filter API
emergency: implement new emergency Maildir delivery
mda: hook up new filter functionality
INSTALL | 3 -
Makefile.PL | 2 -
lib/PublicInbox/Config.pm | 3 +-
lib/PublicInbox/Emergency.pm | 96 +++++++++++
lib/PublicInbox/Filter.pm | 232 ---------------------------
lib/PublicInbox/Filter/Base.pm | 100 ++++++++++++
lib/PublicInbox/Filter/Mirror.pm | 12 ++
lib/PublicInbox/Filter/Vger.pm | 33 ++++
lib/PublicInbox/MDA.pm | 11 +-
script/public-inbox-learn | 42 +++--
script/public-inbox-mda | 135 ++++++++--------
t/emergency.t | 53 ++++++
t/feed.t | 18 +--
t/filter.t | 337 ---------------------------------------
t/filter_base.t | 81 ++++++++++
t/filter_mirror.t | 40 +++++
t/filter_vger.t | 46 ++++++
t/mda.t | 79 ++-------
t/precheck.t | 14 +-
19 files changed, 586 insertions(+), 751 deletions(-)
Note to self: get "git apply" to work on --irreversible-delete patches
^ permalink raw reply [relevance 7%]
* [PATCH 3/9] learn: remove IPC::Run dependency
2016-06-15 0:37 7% [PATCH 0/9] big mda filter changes Eric Wong
@ 2016-06-15 0:37 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-06-15 0:37 UTC (permalink / raw)
To: meta
We'll be relying on our spawn implementation, for now;
since it'll be consistent with the rest of our code and
can optionally take advantage of vfork.
---
script/public-inbox-learn | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/script/public-inbox-learn b/script/public-inbox-learn
index bfbf023..783cf03 100755
--- a/script/public-inbox-learn
+++ b/script/public-inbox-learn
@@ -14,17 +14,35 @@ use Email::MIME;
use Email::MIME::ContentType;
$Email::MIME::ContentType::STRICT_PARAMS = 0; # user input is imperfect
use PublicInbox::Address;
-use IPC::Run qw/run/;
+use PublicInbox::Spawn qw(spawn);
my $train = shift or die "usage: $usage\n";
if ($train !~ /\A(?:ham|spam)\z/) {
die "`$train' not recognized.\nusage: $usage\n";
}
my $pi_config = PublicInbox::Config->new;
+my $err;
my $mime = Email::MIME->new(eval {
local $/;
my $data = scalar <STDIN>;
$data =~ s/\AFrom [^\r\n]*\r?\n//s;
+ eval {
+ my @cmd = (qw(spamc -L), $train);
+ my ($r, $w);
+ pipe($r, $w) or die "pipe failed: $!";
+ open my $null, '>', '/dev/null' or
+ die "failed to open /dev/null: $!";
+ my $nullfd = fileno($null);
+ my %rdr = (0 => fileno($r), 1 => $nullfd, 2 => $nullfd);
+ my $pid = spawn(\@cmd, undef, \%rdr);
+ close $null;
+ close $r or die "close \$r failed: $!";
+ print $w $data or die "print \$w failed: $!";
+ close $w or die "close \$w failed: $!";
+ waitpid($pid, 0);
+ die "spamc failed with: $?\n" if $?;
+ };
+ $err = $@;
$data
});
@@ -43,14 +61,10 @@ if ($train eq "ham") {
PublicInbox::Filter->run($mime);
}
-my $err = 0;
-my @output = qw(> /dev/null > /dev/null);
-
# n.b. message may be cross-posted to multiple public-inboxes
foreach my $recipient (keys %dests) {
my $dst = $pi_config->lookup($recipient) or next;
my $git_dir = $dst->{mainrepo} or next;
- my ($out, $err) = ("", "");
my $git = PublicInbox::Git->new($git_dir);
# We do not touch GIT_COMMITTER_* env here so we can track
# who trained the message.
@@ -74,15 +88,13 @@ foreach my $recipient (keys %dests) {
$im->add($mime);
}
$im->done;
- my $in = $mime->as_string;
- if (!run([qw(spamc -L), $train], \$in, @output)) {
- $err = 1;
- }
-
- $err or eval {
+ eval {
require PublicInbox::SearchIdx;
PublicInbox::SearchIdx->new($git_dir, 2)->index_sync;
};
}
-exit $err;
+if ($err) {
+ warn $err;
+ exit 1;
+}
^ permalink raw reply related [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-06-15 0:37 7% [PATCH 0/9] big mda filter changes Eric Wong
2016-06-15 0:37 6% ` [PATCH 3/9] learn: remove IPC::Run dependency 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).