[PATCH] minor leak in StartTLS

Martin Atkins mart at degeneration.co.uk
Wed Mar 5 18:27:55 UTC 2008


Hi Jacob,

It looks like your patch causes it to share a context across all vhosts, 
which means that all vhosts will end up using the cert from whatever one 
gets initialized first. Am I missing something?

I think it might be necessary to have one ctx per vhost, but I'll admit 
that my knowledge of Net::SSLeay and this bit of DJabberd is limited at 
best.

Cheers,
Martin

Jacob Burkhart wrote:
> There appears to me a minor memory leak in StartTLS, I observe a slow 
> but steady climb in memory usage over the course of hundreds of client 
> SSL connect/disconnects.  Which, I no longer observe when this patch is 
> applied.
> 
> from what I can gather from:
> 
> http://search.cpan.org/~sampo/Net_SSLeay.pm-1.25/SSLeay.pm
> 
> 
> The $ctx created on line 22 of:
> 
> http://code.sixapart.com/trac/djabberd/browser/trunk/DJabberd/lib/DJabberd/Stanza/StartTLS.pm
> 
> 
> needs to be freed with:
> 
> Net::SSLeay::CTX_free ($ctx);
> 
> 
> The other thing going on in StartTLS, is that a new $ctx is being 
> created for every SSL connection, which is not really needed.  It would 
> be more efficient to create a single $ctx (never collect it) and reuse 
> it.  Which is another way to eliminate the need to worry 
> about Net::SSLeay::CTX_free, and thus fix this leak.
> 
> 
> So, I submit for your consideration a patch that makes $ctx an 'our' 
> variable, sets it when first needed, and then reuses it for 
> every Net::SSLeay::new
> 
> 
> thanks,
> 
> Jacob
> 



More information about the Djabberd mailing list