John Peacock said the following on 02/23/2006 03:33 PM: > Robin Bowes wrote: > >>> This was why the original adaptive plugin hook'd reset_transaction; >>> there isn't >>> hook after queue but before post-connection. I think that Johan's >>> earlier >>> suggestion of looking at the transaction object to see which time you >>> want the >>> logging to actually emit something (the middle reset_transaction, in >>> other words). >> >> >> About 1 hour ago it would have saved me ... about 1 hour of hacking! > > > I was thinking and the other way to handle it would be to wrap the > original queue plugin and the put your code there, e.g. in config/plugins: > > logging/queue_wrapper queue/qmail-queue > > and in the queue_wrapper plugin itself: > > sub init { > my ($self, $qp, $queue) = @_; > $self->isa_plugin($queue); > } > > sub hook_queue { > my ($self, $transaction) = @_; > my $return = $self->SUPER::hook_queue($self, $transaction); > if ( $return == OK ) { # message was queued > # perform your logging activity > } > return $return; > } > > *WARNING!!! NOT TESTED* > > The only thing I haven't worked out is how to handle any optional > commandline arguments to the original queue plugin (which may just be a > matter of calling the original plugins init() sub with the appropriate @_).
John, That's certainly another approach. However, it introduces unnecessary coupling between the logging and queueing processes. I'd rather keep them as separate as possible. My preferred approach would be to apply the following simple patch to qmail-queue to return DECLINED instead of OK following successful queueing of the msg: --- qmail-queue 2006-02-23 02:04:42.000000000 +0000 +++ qmail-queue.patched 2006-02-23 21:23:43.000000000 +0000 @@ -76,7 +76,7 @@ my $msg_id = $transaction->header->get('Message-Id') || ''; $msg_id =~ s/[\r\n].*//s; # don't allow newlines in the Message-Id here $msg_id = "<$msg_id>" unless $msg_id =~ /^<.*>$/; # surround in <>'s - return (OK, "Queued! " . time . " qp $child $msg_id"); + return (DECLINED, "Queued! " . time . " qp $child $msg_id"); } elsif (defined $child) { # Child This would allow other plugins hooking queue to execute after the qmail-queue plugin. However, I'm not sure if this has any negative impact in other areas of qpsmtpd. Does anyone know if this will cause any problems? R.