summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Process
diff options
context:
space:
mode:
authorfukachan <fukachan>2006-05-13 11:45:40 +0000
committerfukachan <fukachan>2006-05-13 11:45:40 +0000
commite910a4f5d2e95a96b3fdac9b089fe32c3ebb0a16 (patch)
treeb9f853edb485c521d6cbc23058fd15e263c68549 /fml/lib/FML/Process
parent4480917b1d0080b6d32dc6bd502945e596db0ba5 (diff)
downloadfml8-e910a4f5d2e95a96b3fdac9b089fe32c3ebb0a16.tar.gz
fml8-e910a4f5d2e95a96b3fdac9b089fe32c3ebb0a16.tar.bz2
fml8-e910a4f5d2e95a96b3fdac9b089fe32c3ebb0a16.zip
enable body based loop check
Diffstat (limited to 'fml/lib/FML/Process')
-rw-r--r--fml/lib/FML/Process/Kernel.pm37
-rw-r--r--fml/lib/FML/Process/Utils.pm60
2 files changed, 95 insertions, 2 deletions
diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm
index 45d2f7d9..56553981 100644
--- a/fml/lib/FML/Process/Kernel.pm
+++ b/fml/lib/FML/Process/Kernel.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Kernel.pm,v 1.282 2006/05/04 05:21:29 fukachan Exp $
+# $FML: Kernel.pm,v 1.283 2006/05/12 13:50:11 fukachan Exp $
#
package FML::Process::Kernel;
@@ -668,6 +668,9 @@ sub simple_loop_check
unless ($match) {
$match = $curproc->_header_based_loop_check();
}
+ unless ($match) {
+ $match = $curproc->_body_based_loop_check();
+ }
# $match contains the first matched rule name (== reason).
if ($match) {
@@ -742,6 +745,38 @@ sub _header_based_loop_check
}
+# Descriptions: body based loop check.
+# Arguments: OBJ($curproc)
+# Side Effects: none
+# Return Value: STR
+sub _body_based_loop_check
+{
+ my ($curproc) = @_;
+ my $config = $curproc->config();
+ my $match = undef;
+ my $var_rules = 'incoming_mail_body_loop_check_rules';
+
+ if ($config->yes('use_incoming_mail_body_loop_check')) {
+ use FML::Body;
+ my $body = new FML::Body $curproc;
+
+ my $rules = $config->get_as_array_ref($var_rules);
+ RULE:
+ for my $rule (@$rules) {
+ if ($body->can($rule)) {
+ $match = $body->$rule($config) ? $rule : undef;
+ }
+ else {
+ $curproc->logwarn("body->${rule}() is undefined");
+ }
+ last RULE if $match;
+ }
+ }
+
+ return $match;
+}
+
+
# Descriptions: commit message-id cache update transaction.
# Arguments: OBJ($curproc)
# Side Effects: update cache.
diff --git a/fml/lib/FML/Process/Utils.pm b/fml/lib/FML/Process/Utils.pm
index 898a8382..f74c6f90 100644
--- a/fml/lib/FML/Process/Utils.pm
+++ b/fml/lib/FML/Process/Utils.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Utils.pm,v 1.148 2006/02/15 13:44:04 fukachan Exp $
+# $FML: Utils.pm,v 1.149 2006/04/22 08:29:23 fukachan Exp $
#
package FML::Process::Utils;
@@ -329,6 +329,64 @@ sub incoming_message_remove_queue
}
+=head2 incoming_message_print_body_as_file()
+
+dupliate the body part into a temporary file.
+return a newly created temporary file path.
+
+=cut
+
+
+# Descriptions: dupliate the body part into a temporary file.
+# Arguments: OBJ($curproc) OBJ($queue)
+# Side Effects: create a temporary file.
+# Return Value: STR
+sub incoming_message_print_body_as_file
+{
+ my ($curproc, $queue) = @_;
+ my $cache_file = $curproc->incoming_message_get_cache_file_path();
+ my $tmp_file = $curproc->tmp_file_path();
+
+ if (-f $cache_file) {
+ my $rh = new FileHandle $cache_file;
+ my $wh = new FileHandle "> $tmp_file";
+ if (defined $rh && defined $wh) {
+ my $found = 0;
+ my $buf;
+ LINE:
+ while ($buf = <$rh>) {
+ unless ($found) {
+ if ($buf =~ /^$/o) {
+ $found = 1;
+ }
+ next LINE;
+ }
+ print $wh $buf;
+ }
+ $wh->close();
+ $rh->close();
+
+ return $tmp_file;
+ }
+ else {
+ my $myname = "incoming_message_dup_body";
+ unless (defined $rh) {
+ $curproc->logerror("$myname: cannot open $cache_file");
+ }
+ unless (defined $wh) {
+ $curproc->logerror("$myname: cannot open $tmp_file");
+ }
+
+ return undef;
+ }
+ }
+ else {
+ $curproc->logerror("incoming_message_dup_body: no cache");
+ return undef;
+ }
+}
+
+
=head1 access METHODS to handle article
available only in C<libexec/distribute> process.