On Sun, May 12, 2002 at 08:48:41PM -0700, Marc MERLIN wrote:
> > What about using the bgsend/bgisready functionality in Net::DNS? That
> > should allow multiple queries in the background in parallel.
> 
> Sounds like a great idea, I wasn't aware of the functionality.
> Craig, is it something:
> - you'd be willing to do (as an option for those who don't want the
>   overhead)?
> - you don't want to do yourself but you'd accept as a patch?

In the meantime, here's a little code I wrote (quick dirty logging).
You can use this to log how long each mail was delayed by DNS and razor
queries

In my  case, it's shown  that's it's indeed DNS  queries in the  few minutes
I've been running it (more stats later)

diff -urN Mail.old/SpamAssassin/Dns.pm Mail/SpamAssassin/Dns.pm
--- Mail.old/SpamAssassin/Dns.pm        Sun May 12 22:26:07 2002
+++ Mail/SpamAssassin/Dns.pm    Sun May 12 23:15:07 2002
@@ -56,6 +56,8 @@
   my ($self, $set, $dom, $ip, $found) = @_;
   return $found if $found;
 
+  my $beforetime=time;
+
   my $q = $self->{res}->search ($dom);
 
   if ($q) {
@@ -74,10 +76,14 @@
 
        $self->{$set}->{rbl_IN_As_found} .= $addr.' ';
        $self->{$set}->{rbl_matches_found} .= $ip.' ';
+       my $timedelta=time-$beforetime;
+       $self->log(sprintf("%3d secs: Successful RBL lookup on $set/$dom/$ip", 
+$timedelta));
        return ($found+1);
       }
     }
   }
+  my $timedelta=time-$beforetime;
+  $self->log(sprintf("%3d secs: Unsuccessful RBL lookup on $set/$dom/$ip", 
+$timedelta));
   return 0;
 }
 
@@ -155,6 +161,8 @@
     return 0;
   }
 
+  my $beforetime=time;
+
   my @msg = split (/^/m, $$fulltext);
 
   my $timeout = 10;            # seconds
@@ -177,7 +185,7 @@
     require Razor::Agent;
     local ($^W) = 0;           # argh, warnings in Razor
 
-    local $SIG{ALRM} = sub { die "alarm\n" };
+    local $SIG{ALRM} = sub { $self->log("razor killed"); die "alarm\n" };
     alarm 10;
 
     my $rc = Razor::Client->new ($config, %options);
@@ -220,6 +228,8 @@
     close OLDOUT;
   }
 
+  my $timedelta=time-$beforetime;
+  $self->log(sprintf("%3d secs: Razor run", $timedelta));
   if ((defined $response) && ($response+0)) { return 1; }
   return 0;
 }
@@ -250,6 +260,7 @@
 sub lookup_mx {
   my ($self, $dom) = @_;
 
+  my $beforetime=time;
   return 0 unless $self->load_resolver();
   my $ret = 0;
 
@@ -264,12 +275,15 @@
   }
 
   dbg ("MX for '$dom' exists? $ret");
+  my $timedelta=time-$beforetime;
+  $self->log(sprintf("%3d secs: MX lookup for $dom", $timedelta));
   return $ret;
 }
 
 sub lookup_ptr {
   my ($self, $dom) = @_;
 
+  my $beforetime=time;
   return undef unless $self->load_resolver();
   if ($self->{main}->{local_tests_only}) {
     dbg ("local tests only, not looking up PTR");
@@ -297,6 +311,8 @@
 
   dbg ("PTR for '$dom': '$name'");
 
+  my $timedelta=time-$beforetime;
+  $self->log(sprintf("%3d secs: PTR lookup for $dom", $timedelta));
   # note: undef is never returned, unless DNS is unavailable.
   return $name;
 }
@@ -323,5 +339,18 @@
 }
 
 ###########################################################################
+
+sub log {
+    my ($self, $mesg) = @_;
+    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
+    
+    if (! defined $self->{"logopened"})
+    {
+       open(DEBUGLOG, ">>/var/log/satimes.log") or die "Can't open 
+/var/log/satimes.log: $!";
+       $self->{"logopened"}=1;
+    }
+    printf DEBUGLOG ("%.4d/%.2d/%.2d  %.2d:%.2d:%.2d - %s (on 
+%s)\n",$year+1900,$mon,$mday,$hour,$min,$sec,$mesg,$self->{"mesgid"});
+}
+
 
 1;
diff -urN Mail.old/SpamAssassin.pm Mail/SpamAssassin.pm
--- Mail.old/SpamAssassin.pm    Sun May 12 22:41:33 2002
+++ Mail/SpamAssassin.pm        Sun May 12 22:56:44 2002
@@ -202,6 +202,7 @@
   $self->init(1);
   my $mail = $self->encapsulate_mail_object ($mail_obj);
   my $msg = Mail::SpamAssassin::PerMsgStatus->new($self, $mail);
+  chomp($msg->{"mesgid"} = $mail_obj->get("Message-Id"));
   $msg->check();
   $msg;
 }
-- 
Microsoft is to operating systems & security ....
                                      .... what McDonalds is to gourmet cooking
  
Home page: http://marc.merlins.org/   |   Finger [EMAIL PROTECTED] for PGP key

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to