Skip to content

Commit

Permalink
Support for $transaction->id to get a unique id for this transaction
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@775 958fd67b-6ff1-0310-b445-bb7760255be9
  • Loading branch information
Matt Sergeant committed Aug 28, 2007
1 parent e5653b8 commit a7914ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Qpsmtpd/SMTP.pm
Expand Up @@ -135,7 +135,7 @@ sub transaction {
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);
}


Expand Down
2 changes: 1 addition & 1 deletion lib/Qpsmtpd/TcpServer/Prefork.pm
Expand Up @@ -12,7 +12,7 @@ sub start_connection {

#reset info
$self->{_connection} = Qpsmtpd::Connection->new(); #reset connection
$self->{_transaction} = Qpsmtpd::Transaction->new(); #reset transaction
$self->reset_transaction;
$self->SUPER::start_connection(@_);
}

Expand Down
16 changes: 15 additions & 1 deletion lib/Qpsmtpd/Transaction.pm
Expand Up @@ -4,6 +4,8 @@ use Qpsmtpd;
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);

Expand All @@ -13,11 +15,23 @@ sub start {
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;
Expand Down

0 comments on commit a7914ac

Please sign in to comment.