Author: msergeant
Date: Tue Aug 28 11:42:01 2007
New Revision: 775

Modified:
   trunk/lib/Qpsmtpd/SMTP.pm
   trunk/lib/Qpsmtpd/TcpServer/Prefork.pm
   trunk/lib/Qpsmtpd/Transaction.pm

Log:
Support for $transaction->id to get a unique id for this transaction


Modified: trunk/lib/Qpsmtpd/SMTP.pm
==============================================================================
--- trunk/lib/Qpsmtpd/SMTP.pm   (original)
+++ trunk/lib/Qpsmtpd/SMTP.pm   Tue Aug 28 11:42:01 2007
@@ -135,7 +135,7 @@
 sub reset_transaction {
   my $self = shift;
   $self->run_hooks("reset_transaction") if $self->{_transaction};
-  return $self->{_transaction} = Qpsmtpd::Transaction->new();
+  return $self->{_transaction} = Qpsmtpd::Transaction->new(connection => 
$self->connection);
 }
 
 

Modified: trunk/lib/Qpsmtpd/TcpServer/Prefork.pm
==============================================================================
--- trunk/lib/Qpsmtpd/TcpServer/Prefork.pm      (original)
+++ trunk/lib/Qpsmtpd/TcpServer/Prefork.pm      Tue Aug 28 11:42:01 2007
@@ -12,7 +12,7 @@
 
     #reset info
     $self->{_connection} = Qpsmtpd::Connection->new(); #reset connection
-    $self->{_transaction} = Qpsmtpd::Transaction->new(); #reset transaction
+    $self->reset_transaction;
     $self->SUPER::start_connection(@_);
 }
 

Modified: trunk/lib/Qpsmtpd/Transaction.pm
==============================================================================
--- trunk/lib/Qpsmtpd/Transaction.pm    (original)
+++ trunk/lib/Qpsmtpd/Transaction.pm    Tue Aug 28 11:42:01 2007
@@ -4,6 +4,8 @@
 use strict;
 use Qpsmtpd::Utils;
 use Qpsmtpd::Constants;
+use Socket qw(inet_aton);
+use Time::HiRes qw(time);
 
 use IO::File qw(O_RDWR O_CREAT);
 
@@ -13,11 +15,23 @@
   my $proto = shift;
   my $class = ref($proto) || $proto;
   my %args = @_;
-  my $self = { _rcpt => [], started => time };
+  
+  # generate id
+  my $conn = $args{connection};
+  my $ip = $conn->local_port || "0";
+  my $start = time;
+  my $id = "$start.$$.$ip";
+  
+  my $self = { _rcpt => [], started => $start, _id => $id };
   bless ($self, $class);
   return $self;
 }
 
+sub id {
+  my $self = shift;
+  $self->{_id};
+}
+
 sub add_recipient {
   my $self = shift;
   @_ and push @{$self->{_recipients}}, shift;

Reply via email to