isomorfeus-iodine 0.7.45 → 0.7.48

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",
@@ -10,9 +10,13 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['jan@kursator.de']
11
11
 
12
12
  spec.summary = 'iodine build for Isomorfeus'
13
- spec.description = 'iodine build for Isomorfeus'
14
- spec.homepage = 'https://github.com/janbiedermann/iodine'
13
+ spec.description = 'iodine build for Isomorfeus, original iodine from Bo: https://github.com/boazsegev/iodine'
14
+ spec.homepage = 'https://isomorfeus.com'
15
15
  spec.license = 'MIT'
16
+ spec.metadata = {
17
+ "github_repo" => "ssh://github.com/isomorfeus/gems",
18
+ "source_code_uri" => "https://github.com/isomorfeus/isomorfeus-iodine"
19
+ }
16
20
 
17
21
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
22
  spec.bindir = 'exe'
@@ -21,7 +25,7 @@ Gem::Specification.new do |spec|
21
25
 
22
26
  spec.extensions = %w(ext/iodine/extconf.rb)
23
27
 
24
- spec.required_ruby_version = '>= 2.2.2' # Because earlier versions had been discontinued
28
+ spec.required_ruby_version = '>= 3.1.0'
25
29
 
26
30
  spec.requirements << 'A Unix based system: Linux / macOS / BSD.'
27
31
  spec.requirements << 'An updated C compiler.'
@@ -38,5 +42,5 @@ Gem::Specification.new do |spec|
38
42
  spec.add_development_dependency 'rake-compiler', '>= 1', '< 2.0'
39
43
 
40
44
  spec.post_install_message = "Thank you for installing Iodine #{Iodine::VERSION}.\n" +
41
- "Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations) to Bo."
45
+ "Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations) to Bo, see https://github.com/boazsegev/iodine"
42
46
  end
@@ -1,3 +1,3 @@
1
- module Iodine
2
- VERSION = '0.7.45'.freeze
3
- end
1
+ module Iodine
2
+ VERSION = '0.7.48'.freeze
3
+ end
data/lib/iodine.rb CHANGED
@@ -2,8 +2,8 @@ require 'stringio' # Used internally as a default RackIO
2
2
  require 'socket' # TCPSocket is used internally for Hijack support
3
3
  # require 'openssl' # For SSL/TLS support using OpenSSL
4
4
 
5
- require_relative './iodine/version'
6
- require_relative './iodine/iodine' # loading a binary C extension
5
+ require 'iodine/version'
6
+ require 'iodine/iodine' # loading a binary C extension
7
7
 
8
8
  # Iodine is an HTTP / WebSocket server as well as an Evented Network Tool Library. In essense, Iodine is a Ruby port for the [facil.io](http://facil.io) C library.
9
9
  #
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.48
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: 2022-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -110,7 +110,7 @@ dependencies:
110
110
  - - "<"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '2.0'
113
- description: iodine build for Isomorfeus
113
+ description: 'iodine build for Isomorfeus, original iodine from Bo: https://github.com/boazsegev/iodine'
114
114
  email:
115
115
  - jan@kursator.de
116
116
  executables:
@@ -122,6 +122,7 @@ files:
122
122
  - ".github/ISSUE_TEMPLATE/bug_report.md"
123
123
  - ".github/workflows/ruby.yml"
124
124
  - ".gitignore"
125
+ - ".gitlab-ci.yml"
125
126
  - ".rspec"
126
127
  - ".travis.yml"
127
128
  - ".yardopts"
@@ -141,6 +142,7 @@ files:
141
142
  - bin/poc/config.ru
142
143
  - bin/poc/gemfile
143
144
  - bin/poc/www/index.html
145
+ - bitbucket-pipelines.yml
144
146
  - examples/async_task.ru
145
147
  - examples/config.ru
146
148
  - examples/echo.ru
@@ -237,13 +239,15 @@ files:
237
239
  - lib/iodine/version.rb
238
240
  - lib/rack/handler/iodine.rb
239
241
  - logo.png
240
- homepage: https://github.com/janbiedermann/iodine
242
+ homepage: https://isomorfeus.com
241
243
  licenses:
242
244
  - MIT
243
- metadata: {}
245
+ metadata:
246
+ github_repo: ssh://github.com/isomorfeus/gems
247
+ source_code_uri: https://github.com/isomorfeus/isomorfeus-iodine
244
248
  post_install_message: |-
245
- Thank you for installing Iodine 0.7.45.
246
- Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations) to Bo.
249
+ Thank you for installing Iodine 0.7.48.
250
+ Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations) to Bo, see https://github.com/boazsegev/iodine
247
251
  rdoc_options: []
248
252
  require_paths:
249
253
  - lib
@@ -252,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
256
  requirements:
253
257
  - - ">="
254
258
  - !ruby/object:Gem::Version
255
- version: 2.2.2
259
+ version: 3.1.0
256
260
  required_rubygems_version: !ruby/object:Gem::Requirement
257
261
  requirements:
258
262
  - - ">="
@@ -265,7 +269,7 @@ requirements:
265
269
  - Ruby >= 2.5.0 recommended.
266
270
  - TLS requires OpenSSL >= 1.1.0.
267
271
  - Or Windows with Ruby >= 3.0.0 build with MingW and MingW as compiler.
268
- rubygems_version: 3.2.22
272
+ rubygems_version: 3.3.7
269
273
  signing_key:
270
274
  specification_version: 4
271
275
  summary: iodine build for Isomorfeus