From e6113d586d4c89612e3395094c684dccaddec521 Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Wed, 29 Aug 2007 21:50:53 +0000 Subject: [PATCH] More changes to the id generator git-svn-id: https://svn.perl.org/qpsmtpd/trunk@778 958fd67b-6ff1-0310-b445-bb7760255be9 --- lib/Qpsmtpd/Transaction.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm index 55fd315..a70a69b 100644 --- a/lib/Qpsmtpd/Transaction.pm +++ b/lib/Qpsmtpd/Transaction.pm @@ -5,10 +5,14 @@ use strict; use Qpsmtpd::Utils; use Qpsmtpd::Constants; use Socket qw(inet_aton); +use Sys::Hostname; use Time::HiRes qw(gettimeofday); use IO::File qw(O_RDWR O_CREAT); +my $SALT_HOST => crypt(hostname, chr(65+rand(57)).chr(65+rand(57))); +$SALT_HOST =~ tr/A-Za-z0-9//cd; + sub new { start(@_) } sub start { @@ -16,12 +20,18 @@ sub start { my $class = ref($proto) || $proto; my %args = @_; - # generate id + # Generate unique id # 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 ($start, $mstart) = gettimeofday(); + my $id = sprintf("%d.%06d.%s.%d.%d", + $start, + $mstart, + $SALT_HOST, + rand(10000), + $$, + ); my $self = { _rcpt => [], started => $start, _id => $id }; bless ($self, $class);