Hi there,
Only recently I started playing with openssl, and It seems I am
encountering a memory leak when setting up a simple server using
fork(). Initially I've been suspecting some problems with SSL, but
lately I've been able to limit it to VERY simple use-case.

It is embarassing, but I can not get through this problem. Everything
is fine as long as I stay in a single process, and process one
connection at a time. But when I wanted to get it one step further,
and used fork, some issues appeared...

//accept a client on simple accept BIO
parent:   BIO_new_accept ( host_port=2001 ) : accept_bio
parent:   BIO_do_accept ( b=accept_bio ) : 1
parent:   BIO_do_accept ( b=accept_bio ) : 1
parent:   BIO_pop ( b=accept_bio ) : client_bio

//when client is accepted, server forks
parent:   fork()
//when dealing with casual sockets, after forking client closes accept socket
//(it does not need it), and server closes client (it does not need it neither)

//freeing popped client BIO in parent would disconnect client in child,
//so I can not free it, which will cause 64B memory leak
//parent:   BIO_free ( b=client_bio ) : 1   //???

//freeing accept BIO in child would cause failure in parent's BIO_do_accept
//child:   BIO_free ( b=accept_bio ) : 1   //???

child:   <deal with client>
child:   BIO_free ( b=client_bio ) : 1

1- Why when using BIOs I can't use a casual close-client/close-accept
socket? It seems like reference counting is not working as usual
2- How would I prevent this 64B memory leak? It is a bit painfull,
because my parent process gets bigger and bigger, causing all new
children spawned to be overbloated also
3- What I am doing wrong? ;)

TIA
-- 
Michal Stawinski
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to