Update id generator again

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@777 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2007-08-29 21:37:33 +00:00
parent 3a85914315
commit bf5d011d85
2 changed files with 7 additions and 6 deletions

View File

@ -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(connection => $self->connection);
return $self->{_transaction} = Qpsmtpd::Transaction->new();
}

View File

@ -5,7 +5,7 @@ use strict;
use Qpsmtpd::Utils;
use Qpsmtpd::Constants;
use Socket qw(inet_aton);
use Time::HiRes qw(time);
use Time::HiRes qw(gettimeofday);
use IO::File qw(O_RDWR O_CREAT);
@ -17,10 +17,11 @@ sub start {
my %args = @_;
# generate id
my $conn = $args{connection};
my $ip = $conn->remote_port || "0";
my $start = time;
my $id = "$start.$$.$ip";
# use gettimeofday for microsec precision
my ($start, $mstart) = gettimeofday();
# add in rand() in case gettimeofday clock is slow (e.g. bsd?)
# add in $$ in case srand is set per process
my $id = sprintf("%d.%06d.%d.%d", $start, $mstart, rand(10000), $$);
my $self = { _rcpt => [], started => $start, _id => $id };
bless ($self, $class);