summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_ssl.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-28 09:09:26 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-28 09:09:26 +0000
commit02afafb42ae4ae98140f2c79c67b948e1e6bc577 (patch)
tree293b883b6987a34a31e9f6d215b348c076c46ef9 /ext/openssl/ossl_ssl.c
parent73cf9abd1c88eec81e86f697f29a6cbe58ad3d27 (diff)
* ext/openssl/ossl_ssl.c (ossl_ssl_close): Fix sync_close to work
when SSL is not started. This fix the fd leak by test_https_proxy_authentication in test/net/http/test_https_proxy.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_ssl.c')
-rw-r--r--ext/openssl/ossl_ssl.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index a95ab3d1d0..f314a7ac25 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -1566,18 +1566,22 @@ static VALUE
ossl_ssl_close(VALUE self)
{
SSL *ssl;
+ VALUE io;
- ossl_ssl_data_get_struct(self, ssl);
+ /* ossl_ssl_data_get_struct() is not usable here because it may return
+ * from this function; */
- if (ssl) {
- VALUE io = ossl_ssl_get_io(self);
- if (!RTEST(rb_funcall(io, rb_intern("closed?"), 0))) {
- ossl_ssl_shutdown(ssl);
- SSL_free(ssl);
- DATA_PTR(self) = NULL;
- if (RTEST(ossl_ssl_get_sync_close(self)))
- rb_funcall(io, rb_intern("close"), 0);
- }
+ Data_Get_Struct(self, SSL, ssl);
+
+ io = ossl_ssl_get_io(self);
+ if (!RTEST(rb_funcall(io, rb_intern("closed?"), 0))) {
+ if (ssl) {
+ ossl_ssl_shutdown(ssl);
+ SSL_free(ssl);
+ }
+ DATA_PTR(self) = NULL;
+ if (RTEST(ossl_ssl_get_sync_close(self)))
+ rb_funcall(io, rb_intern("close"), 0);
}
return Qnil;