On Wed, 22 Aug 2007 12:48:09 -0700 JT Moree <[EMAIL PROTECTED]> wrote: > Sydney Bogaert wrote: > > You assume here that the process numbers are different for each message. > > While it will work for forkserver and tcpserver, that is not the case > > with prefork or Apache (also preforking). > > Is there a message ID that is unique to each message? Not until the sending client has submitted a 'Message-ID' header ;-)
But it would be easy to add / generate a transaction id after every reset_transaction() call. This could be logged instead of (or as addition to) the PID. ...something like the attached diff would do. If it's OK, I'll submit to svn trunk. Hmm, the spool filename should also include this transaction id, then it's easier to figure which session was incomplete or is currently running. Hanno
Index: lib/Qpsmtpd/Transaction.pm =================================================================== --- lib/Qpsmtpd/Transaction.pm (revision 774) +++ lib/Qpsmtpd/Transaction.pm (working copy) @@ -207,6 +207,14 @@ return shift->{_body_file}; } +sub id { + my $self = shift; + unless ($self->{_transaction_id}) { + $self->{_transaction_id} = sprintf("%08X", rand(2**32 - 1)); + } + return $self->{_transaction_id}; +} + sub DESTROY { my $self = shift; # would we save some disk flushing if we unlinked the file before Index: plugins/logging/warn =================================================================== --- plugins/logging/warn (revision 774) +++ plugins/logging/warn (working copy) @@ -31,7 +31,8 @@ return DECLINED if defined $plugin and $plugin eq $self->plugin_name; warn - join(" ", $$ . + join(" ", $$ . + ($transaction->sender ? $transaction->id : "00000000"), (defined $plugin ? " $plugin plugin:" : defined $hook ? " running plugin ($hook):" : ""), @log), "\n" Index: plugins/logging/file =================================================================== --- plugins/logging/file (revision 774) +++ plugins/logging/file (working copy) @@ -274,7 +274,9 @@ my $f = $self->{_f}; print $f strftime($self->{_tsformat}, localtime), ' ', - hostname(), '[', $$, ']: ', @log, "\n"; + hostname(), '[', $$, ']: ', + ($txn->sender ? $txn->id : '00000000'),' ', + @log, "\n"; return DECLINED; } Index: lib/Qpsmtpd/SMTP.pm =================================================================== --- lib/Qpsmtpd/SMTP.pm (revision 774) +++ lib/Qpsmtpd/SMTP.pm (working copy) @@ -388,8 +388,8 @@ } else { # includes OK $self->log(LOGINFO, "getting mail from ".$from->format); - $self->respond(250, $from->format . ", sender OK - how exciting to get mail from you!"); $self->transaction->sender($from); + $self->respond(250, $from->format . ", sender OK - your transaction id is ".$self->transaction->id); } }