From a05b334b44db0170419f875b94304d6b55dfc195 Mon Sep 17 00:00:00 2001 From: Hanno Hecker Date: Sun, 18 May 2008 05:55:30 +0000 Subject: [PATCH] reset the original connection object like we reset all connection objects at the end of a connection git-svn-id: https://svn.perl.org/qpsmtpd/trunk@913 958fd67b-6ff1-0310-b445-bb7760255be9 --- lib/Qpsmtpd/Connection.pm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/Qpsmtpd/Connection.pm b/lib/Qpsmtpd/Connection.pm index f14e23b..7020f7f 100644 --- a/lib/Qpsmtpd/Connection.pm +++ b/lib/Qpsmtpd/Connection.pm @@ -38,10 +38,15 @@ sub start { sub clone { my $self = shift; + my %args = @_; my $new = $self->new(); foreach my $f ( @parameters ) { $new->$f($self->$f()) if $self->$f(); } + # reset the old connection object like it's done at the end of a connection + # to prevent leaks (like prefork/tls problem with the old SSL file handle + # still around) + $self->reset unless $args{no_reset}; # should we generate a new id here? return $new; } @@ -196,9 +201,20 @@ set after a successful return from those hooks. Connection-wide notes, used for passing data between plugins. -=head2 clone( ) +=head2 clone([%args]) -Returns a copy of the Qpsmtpd::Connection object. +Returns a copy of the Qpsmtpd::Connection object. The optional args parameter +may contain: + +=over 4 + +=item no_reset (1|0) + +If true, do not reset the original connection object, the author has to care +about that: only the cloned connection object is reset at the end of the +connection + +=back =cut