Guys:
I have a listening socket, waiting for connections from clients. When a
client connects to my server, I put SSL on socket and spin up a thread
to handle it. One client is one thread. All of these connections are
shared by same SSL_CTX ctx. This is the way I handle at the end of this
connection:

1. If (SSL_shutdown(ssl))
2. {
3.  SSL_free(ssl);
4.  SSL_free_ctx();
5   close(socket);
6. }
7. Else
8. {
9.   Throw exception(...);
10. }

Is the right way to do??? Do I need both lines 3 and 4? Please help.

Thank You
TD

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David Schwartz
Sent: Monday, January 08, 2007 21:38
To: openssl-users@openssl.org
Subject: RE: a question about "SSL_CTX_free"


> guys:
>
> the man page for "SSL_CTX_free" says:
> SSL_CTX_free() decrements the reference count of ctx, and removes the 
> SSL_CTX object pointed to by ctx and frees up the allocated memory if 
> the the reference count has reached 0.
> i have a couple of questions regarding this:
>
> 1. what make the reference count of ctx increase/decrease?

Any time another object is created that references it.

> 2. if i call SSL_CTX_free, does that mean all ssl connections based on

> this ctx will be closed automatically? or i should close all ssl 
> connections based on a ctx before i call SSL_CTX_free?

Calling SSL_CTX_free is perfectly safe if you have a reference to the
context and do not plan to use it further. Existing connections will not
be harmed because they have their own references to the context, and the
context will not be freed until its reference count reaches zero.

DS


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to