View | Details | Raw Unified | Return to bug 3839
Collapse All | Expand All

(-)lib/Mail/SpamAssassin.pm (+25 lines)
Lines 1464-1469 Link Here
1464
  # TODO -- open DNS cache etc. if necessary
1464
  # TODO -- open DNS cache etc. if necessary
1465
}
1465
}
1466
1466
1467
sub in_sub_process {
1468
  my ($self, $code) = @_;
1469
  my $rand = rand();
1470
  my $file = ".tmp.$$.$rand.answer";
1471
1472
use Storable;
1473
  my $cpid = fork;
1474
  if ($cpid) {
1475
      wait;
1476
      open (my $fh, $file);
1477
      my $data = do { local $/; <$fh> };
1478
      my $res = eval { Storable::thaw($data); };
1479
      unlink $file;
1480
      return $res;
1481
  }
1482
1483
  my $res = $code->();
1484
  if (open (my $fh, ">$file.writing")) {
1485
      print $fh Storable::nfreeze($res);
1486
      CORE::close($fh);
1487
      rename "$file.writing", $file;
1488
      exit 0;
1489
  }
1490
}
1491
1467
sub read_cf {
1492
sub read_cf {
1468
  my ($self, $allpaths, $desc) = @_;
1493
  my ($self, $allpaths, $desc) = @_;
1469
  return $self->_read_cf_pre($allpaths,$desc,\&get_cf_files_in_dir);
1494
  return $self->_read_cf_pre($allpaths,$desc,\&get_cf_files_in_dir);
(-)lib/Mail/SpamAssassin/Conf.pm (-3 / +27 lines)
Lines 2661-2675 Link Here
2661
###########################################################################
2661
###########################################################################
2662
2662
2663
sub parse_scores_only {
2663
sub parse_scores_only {
2664
  my ($self) = @_;
2665
  $_[0]->{parser}->parse ($_[1], 1);
2664
  $_[0]->{parser}->parse ($_[1], 1);
2666
}
2665
}
2667
2666
2668
sub parse_rules {
2667
sub OLD_parse_rules {
2669
  my ($self) = @_;
2670
  $_[0]->{parser}->parse ($_[1], 0);
2668
  $_[0]->{parser}->parse ($_[1], 0);
2671
}
2669
}
2672
2670
2671
sub parse_rules {
2672
  my ($self, $str) = @_;
2673
2674
  my @wanted = qw( errors descriptions test_types scoreset
2675
    scoreset_current tflags body_tests uri_tests uri_evals head_tests
2676
    head_evals body_evals full_tests full_evals rawbody_tests rawbody_evals
2677
    meta_tests regression_tests rewrite_header user_rules_to_compile
2678
    user_defined_rules headers_spam headers_ham bayes_ignore_headers
2679
    bayes_ignore_from bayes_ignore_to whitelist_from whitelist_allows_relays
2680
    blacklist_from blacklist_to whitelist_to more_spam_to all_spam_to
2681
    trusted_networks internal_networks headers_spam headers_ham
2682
    num_check_received bayes_expiry_pct bayes_expiry_period
2683
    bayes_expiry_max_exponent encapsulated_content_description);
2684
2685
  my $back = $self->{main}->in_sub_process(sub {
2686
    $self->{parser}->parse ($str, 0);
2687
    my %back = ();
2688
    foreach my $want (@wanted) { $back{$want} = $self->{$want}; }
2689
    warn "read config in subprocess";
2690
    return \%back;
2691
  });
2692
2693
  foreach my $want (@wanted) { $self->{$want} = $back->{$want}; }
2694
2695
}
2696
2673
###########################################################################
2697
###########################################################################
2674
2698
2675
sub set_score_set {
2699
sub set_score_set {

Return to bug 3839