>>>>> On Fri, 02 Mar 2007 07:58:14 +0000, Darryl Miles said:
> Delivered-To: [email protected]
> Delivered-To: [email protected]
> 
> Martin Simmons wrote:
> >>>>>> On Thu, 01 Mar 2007 11:40:24 +0100, Peter Sylvester said:
> >> The crtl function basically would do:
> >>
> >>    CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX)
> >>
> >> assuming that calling this directly in the application is not an external
> >> interface.
> > 
> > I think you are kind of right, but there's another possibility.
> > 
> > Does the other instance call SSL_free as well?  Note that SSL_free also 
> > calls
> > SSL_CTX_free, so I suspect your call to SSL_CTX_free is not needed (except 
> > in
> > by whoever called SSL_CTX_new).  Consider how you would make it work if you
> > had three SSL objects sharing the same SSL_CTX.
> 
> No.
> 
> Thats now how reference counting works.  If you called a 
> SSL_FOOBAR_new() function which creates a new object and increments the 
> reference counter.  Then its also your responsibility to call 
> SSL_FOOBAR_free() to revert that increment.

Sorry, I couldn't decide who that "No" was addressed to.

Maybe we are just agreeing -- since there was only one call to SSL_CTX_new in
the userapp, there should only be one call to SSL_CTX_free in the userapp.


> You are correct SSL_free() also calls SSL_CTX_free() but this is only to 
> counteract the increment SSL_new() made on the SSL_CTX * it was passed.

Yes, I know, but that was not the problem raised by the OP.

The OP's problem was that he is making a second reference to the SSL_CTX
without incrementing the reference count (because there is no API to
incrementing it!).  That is not ideal, because it forces the userapp to have
its own mechanism for tracking its references to SSL_CTX, in order to call
SSL_CTX_free only once.

__Martin
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to