isomorfeus-iodine 0.7.45 → 0.7.46

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,142 +1,142 @@
1
- #include "iodine.h"
2
-
3
- #include "iodine_store.h"
4
-
5
- #include <inttypes.h>
6
- #include <stdint.h>
7
-
8
- #define FIO_SET_NAME fio_store
9
- #define FIO_SET_OBJ_TYPE uintptr_t
10
- #include <fio.h>
11
-
12
- static fio_lock_i iodine_storage_lock = FIO_LOCK_INIT;
13
- static fio_store_s iodine_storage = FIO_SET_INIT;
14
- static size_t iodine_storage_count_max = 0;
15
-
16
- #ifndef IODINE_DEBUG
17
- #define IODINE_DEBUG 0
18
- #endif
19
-
20
- /* *****************************************************************************
21
- API
22
- ***************************************************************************** */
23
-
24
- /** Adds an object to the storage (or increases it's reference count). */
25
- static VALUE storage_add(VALUE obj) {
26
- if (!obj || obj == Qnil || obj == Qtrue || obj == Qfalse)
27
- return obj;
28
- uintptr_t old = 0;
29
- fio_lock(&iodine_storage_lock);
30
- fio_store_overwrite(&iodine_storage, obj, 1, &old);
31
- if (old)
32
- fio_store_overwrite(&iodine_storage, obj, old + 1, NULL);
33
- if (iodine_storage_count_max < fio_store_count(&iodine_storage))
34
- iodine_storage_count_max = fio_store_count(&iodine_storage);
35
- fio_unlock(&iodine_storage_lock);
36
- return obj;
37
- }
38
- /** Removes an object from the storage (or decreases it's reference count). */
39
- static VALUE storage_remove(VALUE obj) {
40
- if (!obj || obj == Qnil || obj == Qtrue || obj == Qfalse ||
41
- iodine_storage.count == 0)
42
- return obj;
43
- fio_lock(&iodine_storage_lock);
44
- uintptr_t old = 0;
45
- fio_store_remove(&iodine_storage, obj, 0, &old);
46
- if (old > 1)
47
- fio_store_overwrite(&iodine_storage, obj, old - 1, NULL);
48
- fio_unlock(&iodine_storage_lock);
49
- return obj;
50
- }
51
- /** Should be called after forking to reset locks */
52
- static void storage_after_fork(void) { iodine_storage_lock = FIO_LOCK_INIT; }
53
-
54
- /** Prints debugging information to the console. */
55
- static void storage_print(void) {
56
- FIO_LOG_DEBUG("Ruby <=> C Memory storage stats (pid: %d):\n", getpid());
57
- fio_lock(&iodine_storage_lock);
58
- uintptr_t index = 0;
59
- FIO_SET_FOR_LOOP(&iodine_storage, pos) {
60
- if (pos->obj) {
61
- fprintf(stderr, "[%" PRIuPTR "] => %" PRIuPTR " X obj %p type %d\n",
62
- index++, pos->obj, (void *)pos->hash, TYPE(pos->hash));
63
- }
64
- }
65
- fprintf(stderr, "Total of %" PRIuPTR " objects protected form GC\n", index);
66
- fprintf(stderr,
67
- "Storage uses %" PRIuPTR " Hash bins for %" PRIuPTR " objects\n"
68
- "The largest collection was %zu objects.\n",
69
- iodine_storage.capa, iodine_storage.count, iodine_storage_count_max);
70
- fio_unlock(&iodine_storage_lock);
71
- }
72
-
73
- /**
74
- * Used for debugging purposes (when testing iodine for Ruby object "leaks").
75
- */
76
- static VALUE storage_print_rb(VALUE self) {
77
- storage_print();
78
- return Qnil;
79
- (void)self;
80
- }
81
- /* *****************************************************************************
82
- GC protection
83
- ***************************************************************************** */
84
-
85
- /* a callback for the GC (marking active objects) */
86
- static void storage_mark(void *ignore) {
87
- (void)ignore;
88
- if (FIO_LOG_LEVEL >= FIO_LOG_LEVEL_DEBUG)
89
- storage_print();
90
- fio_lock(&iodine_storage_lock);
91
- // fio_store_compact(&iodine_storage);
92
- FIO_SET_FOR_LOOP(&iodine_storage, pos) {
93
- if (pos->obj) {
94
- rb_gc_mark((VALUE)pos->hash);
95
- }
96
- }
97
- fio_unlock(&iodine_storage_lock);
98
- }
99
-
100
- /* clear the registry (end of lifetime) */
101
- static void storage_clear(void *ignore) {
102
- (void)ignore;
103
- FIO_LOG_DEBUG("Ruby<=>C Storage cleared.\n");
104
- fio_lock(&iodine_storage_lock);
105
- fio_store_free(&iodine_storage);
106
- iodine_storage = (fio_store_s)FIO_SET_INIT;
107
- fio_unlock(&iodine_storage_lock);
108
- }
109
-
110
- /*
111
- the data-type used to identify the registry
112
- this sets the callbacks.
113
- */
114
- static const struct rb_data_type_struct storage_type_struct = {
115
- .wrap_struct_name = "RubyReferencesIn_C_Land",
116
- .function.dfree = (void (*)(void *))storage_clear,
117
- .function.dmark = (void (*)(void *))storage_mark,
118
- };
119
-
120
- /* *****************************************************************************
121
- Initialization
122
- ***************************************************************************** */
123
-
124
- struct IodineStorage_s IodineStore = {
125
- .add = storage_add,
126
- .remove = storage_remove,
127
- .after_fork = storage_after_fork,
128
- .print = storage_print,
129
- };
130
-
131
- /** Initializes the storage unit for first use. */
132
- void iodine_storage_init(void) {
133
- fio_store_capa_require(&iodine_storage, 512);
134
- VALUE tmp =
135
- rb_define_class_under(rb_cObject, "IodineObjectStorage", rb_cData);
136
- VALUE storage_obj =
137
- TypedData_Wrap_Struct(tmp, &storage_type_struct, &iodine_storage);
138
- // rb_global_variable(&iodine_storage_obj);
139
- rb_ivar_set(IodineModule, rb_intern2("storage", 7), storage_obj);
140
- rb_define_module_function(IodineBaseModule, "db_print_protected_objects",
141
- storage_print_rb, 0);
142
- }
1
+ #include "iodine.h"
2
+
3
+ #include "iodine_store.h"
4
+
5
+ #include <inttypes.h>
6
+ #include <stdint.h>
7
+
8
+ #define FIO_SET_NAME fio_store
9
+ #define FIO_SET_OBJ_TYPE uintptr_t
10
+ #include <fio.h>
11
+
12
+ static fio_lock_i iodine_storage_lock = FIO_LOCK_INIT;
13
+ static fio_store_s iodine_storage = FIO_SET_INIT;
14
+ static size_t iodine_storage_count_max = 0;
15
+
16
+ #ifndef IODINE_DEBUG
17
+ #define IODINE_DEBUG 0
18
+ #endif
19
+
20
+ /* *****************************************************************************
21
+ API
22
+ ***************************************************************************** */
23
+
24
+ /** Adds an object to the storage (or increases it's reference count). */
25
+ static VALUE storage_add(VALUE obj) {
26
+ if (!obj || obj == Qnil || obj == Qtrue || obj == Qfalse)
27
+ return obj;
28
+ uintptr_t old = 0;
29
+ fio_lock(&iodine_storage_lock);
30
+ fio_store_overwrite(&iodine_storage, obj, 1, &old);
31
+ if (old)
32
+ fio_store_overwrite(&iodine_storage, obj, old + 1, NULL);
33
+ if (iodine_storage_count_max < fio_store_count(&iodine_storage))
34
+ iodine_storage_count_max = fio_store_count(&iodine_storage);
35
+ fio_unlock(&iodine_storage_lock);
36
+ return obj;
37
+ }
38
+ /** Removes an object from the storage (or decreases it's reference count). */
39
+ static VALUE storage_remove(VALUE obj) {
40
+ if (!obj || obj == Qnil || obj == Qtrue || obj == Qfalse ||
41
+ iodine_storage.count == 0)
42
+ return obj;
43
+ fio_lock(&iodine_storage_lock);
44
+ uintptr_t old = 0;
45
+ fio_store_remove(&iodine_storage, obj, 0, &old);
46
+ if (old > 1)
47
+ fio_store_overwrite(&iodine_storage, obj, old - 1, NULL);
48
+ fio_unlock(&iodine_storage_lock);
49
+ return obj;
50
+ }
51
+ /** Should be called after forking to reset locks */
52
+ static void storage_after_fork(void) { iodine_storage_lock = FIO_LOCK_INIT; }
53
+
54
+ /** Prints debugging information to the console. */
55
+ static void storage_print(void) {
56
+ FIO_LOG_DEBUG("Ruby <=> C Memory storage stats (pid: %d):\n", getpid());
57
+ fio_lock(&iodine_storage_lock);
58
+ uintptr_t index = 0;
59
+ FIO_SET_FOR_LOOP(&iodine_storage, pos) {
60
+ if (pos->obj) {
61
+ fprintf(stderr, "[%" PRIuPTR "] => %" PRIuPTR " X obj %p type %d\n",
62
+ index++, pos->obj, (void *)pos->hash, TYPE(pos->hash));
63
+ }
64
+ }
65
+ fprintf(stderr, "Total of %" PRIuPTR " objects protected form GC\n", index);
66
+ fprintf(stderr,
67
+ "Storage uses %" PRIuPTR " Hash bins for %" PRIuPTR " objects\n"
68
+ "The largest collection was %zu objects.\n",
69
+ iodine_storage.capa, iodine_storage.count, iodine_storage_count_max);
70
+ fio_unlock(&iodine_storage_lock);
71
+ }
72
+
73
+ /**
74
+ * Used for debugging purposes (when testing iodine for Ruby object "leaks").
75
+ */
76
+ static VALUE storage_print_rb(VALUE self) {
77
+ storage_print();
78
+ return Qnil;
79
+ (void)self;
80
+ }
81
+ /* *****************************************************************************
82
+ GC protection
83
+ ***************************************************************************** */
84
+
85
+ /* a callback for the GC (marking active objects) */
86
+ static void storage_mark(void *ignore) {
87
+ (void)ignore;
88
+ if (FIO_LOG_LEVEL >= FIO_LOG_LEVEL_DEBUG)
89
+ storage_print();
90
+ fio_lock(&iodine_storage_lock);
91
+ // fio_store_compact(&iodine_storage);
92
+ FIO_SET_FOR_LOOP(&iodine_storage, pos) {
93
+ if (pos->obj) {
94
+ rb_gc_mark((VALUE)pos->hash);
95
+ }
96
+ }
97
+ fio_unlock(&iodine_storage_lock);
98
+ }
99
+
100
+ /* clear the registry (end of lifetime) */
101
+ static void storage_clear(void *ignore) {
102
+ (void)ignore;
103
+ FIO_LOG_DEBUG("Ruby<=>C Storage cleared.\n");
104
+ fio_lock(&iodine_storage_lock);
105
+ fio_store_free(&iodine_storage);
106
+ iodine_storage = (fio_store_s)FIO_SET_INIT;
107
+ fio_unlock(&iodine_storage_lock);
108
+ }
109
+
110
+ /*
111
+ the data-type used to identify the registry
112
+ this sets the callbacks.
113
+ */
114
+ static const struct rb_data_type_struct storage_type_struct = {
115
+ .wrap_struct_name = "RubyReferencesIn_C_Land",
116
+ .function.dfree = (void (*)(void *))storage_clear,
117
+ .function.dmark = (void (*)(void *))storage_mark,
118
+ };
119
+
120
+ /* *****************************************************************************
121
+ Initialization
122
+ ***************************************************************************** */
123
+
124
+ struct IodineStorage_s IodineStore = {
125
+ .add = storage_add,
126
+ .remove = storage_remove,
127
+ .after_fork = storage_after_fork,
128
+ .print = storage_print,
129
+ };
130
+
131
+ /** Initializes the storage unit for first use. */
132
+ void iodine_storage_init(void) {
133
+ fio_store_capa_require(&iodine_storage, 512);
134
+ VALUE tmp =
135
+ rb_define_class_under(rb_cObject, "IodineObjectStorage", rb_cObject);
136
+ VALUE storage_obj =
137
+ TypedData_Wrap_Struct(tmp, &storage_type_struct, &iodine_storage);
138
+ // rb_global_variable(&iodine_storage_obj);
139
+ rb_ivar_set(IodineModule, rb_intern2("storage", 7), storage_obj);
140
+ rb_define_module_function(IodineBaseModule, "db_print_protected_objects",
141
+ storage_print_rb, 0);
142
+ }
@@ -241,7 +241,7 @@ void iodine_init_tls(void) {
241
241
  IODINE_MAKE_SYM(private_key);
242
242
  IODINE_MAKE_SYM(password);
243
243
 
244
- IodineTLSClass = rb_define_class_under(IodineModule, "TLS", rb_cData);
244
+ IodineTLSClass = rb_define_class_under(IodineModule, "TLS", rb_cObject);
245
245
  rb_define_alloc_func(IodineTLSClass, iodine_tls_data_alloc_c);
246
246
  rb_define_method(IodineTLSClass, "initialize", iodine_tls_new, -1);
247
247
  rb_define_method(IodineTLSClass, "use_certificate",
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency 'rspec', '>=3.9.0', '< 4.0'
37
37
  spec.add_development_dependency 'spec', '>=5.3.0', '< 6.0'
38
38
  spec.add_development_dependency 'rake-compiler', '>= 1', '< 2.0'
39
+ spec.required_ruby_version = '>= 3.1.0'
39
40
 
40
41
  spec.post_install_message = "Thank you for installing Iodine #{Iodine::VERSION}.\n" +
41
42
  "Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations) to Bo."
@@ -1,3 +1,3 @@
1
- module Iodine
2
- VERSION = '0.7.45'.freeze
3
- end
1
+ module Iodine
2
+ VERSION = '0.7.46'.freeze
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-iodine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.45
4
+ version: 0.7.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-10 00:00:00.000000000 Z
11
+ date: 2021-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -242,7 +242,7 @@ licenses:
242
242
  - MIT
243
243
  metadata: {}
244
244
  post_install_message: |-
245
- Thank you for installing Iodine 0.7.45.
245
+ Thank you for installing Iodine 0.7.46.
246
246
  Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations) to Bo.
247
247
  rdoc_options: []
248
248
  require_paths:
@@ -252,7 +252,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
252
  requirements:
253
253
  - - ">="
254
254
  - !ruby/object:Gem::Version
255
- version: 2.2.2
255
+ version: 3.1.0
256
256
  required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  requirements:
258
258
  - - ">="
@@ -265,7 +265,7 @@ requirements:
265
265
  - Ruby >= 2.5.0 recommended.
266
266
  - TLS requires OpenSSL >= 1.1.0.
267
267
  - Or Windows with Ruby >= 3.0.0 build with MingW and MingW as compiler.
268
- rubygems_version: 3.2.22
268
+ rubygems_version: 3.3.3
269
269
  signing_key:
270
270
  specification_version: 4
271
271
  summary: iodine build for Isomorfeus