Skip to content

Commit 6788b2f

Browse files
mark openssl classes as being shareable when frozen
1 parent 8367b16 commit 6788b2f

25 files changed

+41
-40
lines changed

ext/openssl/ossl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#include <errno.h>
1818
#include <ruby/io.h>
1919
#include <ruby/thread.h>
20+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
21+
#include <ruby/ractor.h>
22+
#else
23+
#define RUBY_TYPED_FROZEN_SHAREABLE 0
24+
#endif
2025
#include <openssl/opensslv.h>
2126

2227
#include <openssl/err.h>

ext/openssl/ossl_bn.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
/* modified by Michal Rokos <m.rokos@sh.cvut.cz> */
1111
#include "ossl.h"
1212

13-
#ifdef HAVE_RB_EXT_RACTOR_SAFE
14-
#include <ruby/ractor.h>
15-
#endif
16-
1713
#define NewBN(klass) \
1814
TypedData_Wrap_Struct((klass), &ossl_bn_type, 0)
1915
#define SetBN(obj, bn) do { \
@@ -41,7 +37,7 @@ static const rb_data_type_t ossl_bn_type = {
4137
{
4238
0, ossl_bn_free,
4339
},
44-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
40+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
4541
};
4642

4743
/*

ext/openssl/ossl_cipher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static const rb_data_type_t ossl_cipher_type = {
4242
{
4343
0, ossl_cipher_free,
4444
},
45-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
45+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
4646
};
4747

4848
/*

ext/openssl/ossl_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static const rb_data_type_t ossl_config_type = {
2222
{
2323
0, nconf_free,
2424
},
25-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
25+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
2626
};
2727

2828
CONF *

ext/openssl/ossl_digest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static const rb_data_type_t ossl_digest_type = {
3535
{
3636
0, ossl_digest_free,
3737
},
38-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
38+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
3939
};
4040

4141
/*

ext/openssl/ossl_engine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static const rb_data_type_t ossl_engine_type = {
7878
{
7979
0, ossl_engine_free,
8080
},
81-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
81+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
8282
};
8383

8484
/*

ext/openssl/ossl_hmac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static const rb_data_type_t ossl_hmac_type = {
4242
{
4343
0, ossl_hmac_free,
4444
},
45-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
45+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
4646
};
4747

4848
static VALUE

ext/openssl/ossl_ns_spki.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static const rb_data_type_t ossl_netscape_spki_type = {
5050
{
5151
0, ossl_netscape_spki_free,
5252
},
53-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
53+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
5454
};
5555

5656
static VALUE

ext/openssl/ossl_ocsp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static const rb_data_type_t ossl_ocsp_request_type = {
8686
{
8787
0, ossl_ocsp_request_free,
8888
},
89-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
89+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
9090
};
9191

9292
static void
@@ -100,7 +100,7 @@ static const rb_data_type_t ossl_ocsp_response_type = {
100100
{
101101
0, ossl_ocsp_response_free,
102102
},
103-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
103+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
104104
};
105105

106106
static void
@@ -114,7 +114,7 @@ static const rb_data_type_t ossl_ocsp_basicresp_type = {
114114
{
115115
0, ossl_ocsp_basicresp_free,
116116
},
117-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
117+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
118118
};
119119

120120
static void
@@ -128,7 +128,7 @@ static const rb_data_type_t ossl_ocsp_singleresp_type = {
128128
{
129129
0, ossl_ocsp_singleresp_free,
130130
},
131-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
131+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
132132
};
133133

134134
static void
@@ -142,7 +142,7 @@ static const rb_data_type_t ossl_ocsp_certid_type = {
142142
{
143143
0, ossl_ocsp_certid_free,
144144
},
145-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
145+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
146146
};
147147

148148
/*

ext/openssl/ossl_pkcs12.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static const rb_data_type_t ossl_pkcs12_type = {
4444
{
4545
0, ossl_pkcs12_free,
4646
},
47-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
47+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
4848
};
4949

5050
static VALUE

0 commit comments

Comments
 (0)