diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2017-08-23 11:25:29 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2017-08-23 14:37:17 +0900 |
commit | 6a79a06a78ad74441a58da166e108b656aa89f61 (patch) | |
tree | 766121413763d2eb9fe48de991b3fd8f89f0af0a /ext/openssl | |
parent | df37b7a22eb0c70ddba4722630662b4c1e73b009 (diff) | |
download | ruby-openssl-6a79a06a78ad74441a58da166e108b656aa89f61.tar.gz |
ssl: do not call session_remove_cb during GC
As noted in the SSL_CTX_sess_set_remove_cb(3) manpage, SSL_CTX_free()
will call the callback function for each session in the internal session
store. We can't call the callback Proc since it may do a new object
allocation which is prohibited during GC.
Diffstat (limited to 'ext/openssl')
-rw-r--r-- | ext/openssl/ossl_ssl.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index 62bffe31..f0462eda 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -476,6 +476,13 @@ ossl_sslctx_session_remove_cb(SSL_CTX *ctx, SSL_SESSION *sess) void *ptr; int state = 0; + /* + * This callback is also called for all sessions in the internal store + * when SSL_CTX_free() is called. + */ + if (rb_during_gc()) + return; + OSSL_Debug("SSL SESSION remove callback entered"); if ((ptr = SSL_CTX_get_ex_data(ctx, ossl_ssl_ex_ptr_idx)) == NULL) |