Support for $transaction->id to get a unique id for this transaction
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@775 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
e5653b86fc
commit
a7914ac0dc
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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(@_);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user