Author: msergeant
Date: Wed Aug 29 14:37:33 2007
New Revision: 777
Modified:
trunk/lib/Qpsmtpd/SMTP.pm
trunk/lib/Qpsmtpd/Transaction.pm
Log:
Update id generator again
Modified: trunk/lib/Qpsmtpd/SMTP.pm
==============================================================================
--- trunk/lib/Qpsmtpd/SMTP.pm (original)
+++ trunk/lib/Qpsmtpd/SMTP.pm Wed Aug 29 14:37:33 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(connection =>
$self->connection);
+ return $self->{_transaction} = Qpsmtpd::Transaction->new();
}
Modified: trunk/lib/Qpsmtpd/Transaction.pm
==============================================================================
--- trunk/lib/Qpsmtpd/Transaction.pm (original)
+++ trunk/lib/Qpsmtpd/Transaction.pm Wed Aug 29 14:37:33 2007
@@ -5,7 +5,7 @@
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 @@
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);