Since BIO is creating the SSL object somewhere in the call to BIO_new_ssl_connect(Ctx); the cleanup of the SSL object (SSL_shutdown & SSL_free) maybe handled by BIO_free_all()
>> begin else printf("BIO_new_ssl_connect failed.\n"); BIO_free_all(Bio); /* if (Ssl) { SSL_shutdown(Ssl); SSL_free(Ssl); } */ << end -----Original Message----- From: owner-openssl-us...@openssl.org [mailto:owner-openssl-us...@openssl.org] On Behalf Of Matthew Allen Sent: Wednesday, April 21, 2010 7:00 PM To: openssl-users@openssl.org Subject: Re: Socket left in CLOSE_WAIT state... ---------- Original Message ---------- To: (openssl-users@openssl.org) From: Stuart Weatherby (stuart_weathe...@yahoo.ca) Subject: Re: Socket left in CLOSE_WAIT state... Date: 22/4/2010 5:18:48a > Shutdown disables the ability to read, write (or both) on a > socket. However, shutdown() does not close the socket. to release the > socket descriptor back to the OS you also need to call closesocket(); This code does want I want: int r = 0; if ((r = SSL_shutdown(Ssl)) >= 0) { closesocket(SSL_get_fd(Ssl)); } But it seems like an ugly hack. It _should_ close the socket by itself. I'm worried that this leakes some BIO object(s), because clearly if the BIO objects were free'd they'd close their SOCKET. And since that ISN'T happening maybe the BIO object is not being free [correctly]. > Saju Paul wrote: > Looks like it needs a BIO_free_all(bio) or something similair. I tried that before and after the SSL_shutdown call and it just crashes, clearly thats not the "proper" way. Maybe there is a way to disassociate the BIO from the SSL but it seems like a hack rather than a solution. Thanks for the responses. PS in investigating these issues I did try and download + build OpenSSL 1.0.0 for myself, hoping to step into the code and see where things went, but after following the instructions to build with Visual C++ I got stuck running a command that never finished. The perl "do_ms" thing would run for hours using up 100% of the core it was running on and just never seem to finish. Ended up killing it and posting on the mailing list instead. Just FYI. -- Matthew Allen http://www.memecode.com ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.814 / Virus Database: 271.1.1/2827 - Release Date: 04/21/10 14:31:00 ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org