iodine 0.7.58 → 0.7.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- #include "iodine.h"
2
-
3
1
  #include "iodine_store.h"
4
2
 
5
3
  #include <inttypes.h>
6
4
  #include <stdint.h>
7
5
 
8
- #define FIO_SET_NAME fio_store
6
+ #include "iodine.h"
7
+
8
+ #define FIO_SET_NAME fio_store
9
9
  #define FIO_SET_OBJ_TYPE uintptr_t
10
10
  #include <fio.h>
11
11
 
@@ -23,13 +23,11 @@ API
23
23
 
24
24
  /** Adds an object to the storage (or increases it's reference count). */
25
25
  static VALUE storage_add(VALUE obj) {
26
- if (!obj || obj == Qnil || obj == Qtrue || obj == Qfalse)
27
- return obj;
26
+ if (!obj || obj == Qnil || obj == Qtrue || obj == Qfalse) return obj;
28
27
  uintptr_t old = 0;
29
28
  fio_lock(&iodine_storage_lock);
30
29
  fio_store_overwrite(&iodine_storage, obj, 1, &old);
31
- if (old)
32
- fio_store_overwrite(&iodine_storage, obj, old + 1, NULL);
30
+ if (old) fio_store_overwrite(&iodine_storage, obj, old + 1, NULL);
33
31
  if (iodine_storage_count_max < fio_store_count(&iodine_storage))
34
32
  iodine_storage_count_max = fio_store_count(&iodine_storage);
35
33
  fio_unlock(&iodine_storage_lock);
@@ -43,8 +41,7 @@ static VALUE storage_remove(VALUE obj) {
43
41
  fio_lock(&iodine_storage_lock);
44
42
  uintptr_t old = 0;
45
43
  fio_store_remove(&iodine_storage, obj, 0, &old);
46
- if (old > 1)
47
- fio_store_overwrite(&iodine_storage, obj, old - 1, NULL);
44
+ if (old > 1) fio_store_overwrite(&iodine_storage, obj, old - 1, NULL);
48
45
  fio_unlock(&iodine_storage_lock);
49
46
  return obj;
50
47
  }
@@ -58,15 +55,22 @@ static void storage_print(void) {
58
55
  uintptr_t index = 0;
59
56
  FIO_SET_FOR_LOOP(&iodine_storage, pos) {
60
57
  if (pos->obj) {
61
- fprintf(stderr, "[%" PRIuPTR "] => %" PRIuPTR " X obj %p type %d\n",
62
- index++, pos->obj, (void *)pos->hash, TYPE(pos->hash));
58
+ fprintf(stderr,
59
+ "[%" PRIuPTR "] => %" PRIuPTR " X obj %p type %d\n",
60
+ index++,
61
+ pos->obj,
62
+ (void *)pos->hash,
63
+ TYPE(pos->hash));
63
64
  }
64
65
  }
65
66
  fprintf(stderr, "Total of %" PRIuPTR " objects protected form GC\n", index);
66
67
  fprintf(stderr,
67
- "Storage uses %" PRIuPTR " Hash bins for %" PRIuPTR " objects\n"
68
+ "Storage uses %" PRIuPTR " Hash bins for %" PRIuPTR
69
+ " objects\n"
68
70
  "The largest collection was %zu objects.\n",
69
- iodine_storage.capa, iodine_storage.count, iodine_storage_count_max);
71
+ iodine_storage.capa,
72
+ iodine_storage.count,
73
+ iodine_storage_count_max);
70
74
  fio_unlock(&iodine_storage_lock);
71
75
  }
72
76
 
@@ -85,8 +89,7 @@ GC protection
85
89
  /* a callback for the GC (marking active objects) */
86
90
  static void storage_mark(void *ignore) {
87
91
  (void)ignore;
88
- if (FIO_LOG_LEVEL >= FIO_LOG_LEVEL_DEBUG)
89
- storage_print();
92
+ if (FIO_LOG_LEVEL >= FIO_LOG_LEVEL_DEBUG) storage_print();
90
93
  fio_lock(&iodine_storage_lock);
91
94
  // fio_store_compact(&iodine_storage);
92
95
  FIO_SET_FOR_LOOP(&iodine_storage, pos) {
@@ -133,10 +136,13 @@ void iodine_storage_init(void) {
133
136
  fio_store_capa_require(&iodine_storage, 512);
134
137
  VALUE tmp =
135
138
  rb_define_class_under(rb_cObject, "IodineObjectStorage", rb_cObject);
139
+ rb_undef_alloc_func(tmp);
136
140
  VALUE storage_obj =
137
141
  TypedData_Wrap_Struct(tmp, &storage_type_struct, &iodine_storage);
138
142
  // rb_global_variable(&iodine_storage_obj);
139
143
  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);
144
+ rb_define_module_function(IodineBaseModule,
145
+ "db_print_protected_objects",
146
+ storage_print_rb,
147
+ 0);
142
148
  }
@@ -99,7 +99,7 @@ void free_ws_buffer(ws_s *owner, struct buffer_s buff) {
99
99
  Create/Destroy the websocket object (prototypes)
100
100
  */
101
101
 
102
- static ws_s *new_websocket();
102
+ static ws_s *new_websocket(intptr_t uuid);
103
103
  static void destroy_ws(ws_s *ws);
104
104
 
105
105
  /*******************************************************************************
@@ -190,19 +190,15 @@ static void websocket_on_protocol_ping(void *ws_p, void *msg_, uint64_t len) {
190
190
  fio_write2(ws->fd, .data.buffer = buff, .length = len);
191
191
  } else {
192
192
  if (((ws_s *)ws)->is_client) {
193
- fio_write2(ws->fd, .data.buffer = "\x8a\x80mask", .length = 6,
193
+ fio_write2(ws->fd, .data.buffer = "\x89\x80mask", .length = 2,
194
194
  .after.dealloc = FIO_DEALLOC_NOOP);
195
195
  } else {
196
- fio_write2(ws->fd, .data.buffer = "\x8a\x00", .length = 2,
196
+ fio_write2(ws->fd, .data.buffer = "\x89\x00", .length = 2,
197
197
  .after.dealloc = FIO_DEALLOC_NOOP);
198
198
  }
199
199
  }
200
- FIO_LOG_DEBUG("Received ping and sent pong for Websocket %p (%d)", ws_p,
201
- (int)(((ws_s *)ws_p)->fd));
202
200
  }
203
201
  static void websocket_on_protocol_pong(void *ws_p, void *msg, uint64_t len) {
204
- FIO_LOG_DEBUG("Received pong for Websocket %p (%d)", ws_p,
205
- (int)(((ws_s *)ws_p)->fd));
206
202
  (void)len;
207
203
  (void)msg;
208
204
  (void)ws_p;
@@ -250,10 +246,10 @@ static uint8_t on_shutdown(intptr_t fd, fio_protocol_s *ws) {
250
246
  if (ws && ((ws_s *)ws)->on_shutdown)
251
247
  ((ws_s *)ws)->on_shutdown((ws_s *)ws);
252
248
  if (((ws_s *)ws)->is_client) {
253
- fio_write2(fd, .data.buffer = "\x88\x80MASK", .length = 6,
249
+ fio_write2(fd, .data.buffer = "\x8a\x80MASK", .length = 6,
254
250
  .after.dealloc = FIO_DEALLOC_NOOP);
255
251
  } else {
256
- fio_write2(fd, .data.buffer = "\x88\x00", .length = 2,
252
+ fio_write2(fd, .data.buffer = "\x8a\x00", .length = 2,
257
253
  .after.dealloc = FIO_DEALLOC_NOOP);
258
254
  }
259
255
  return 0;
@@ -740,13 +736,8 @@ int websocket_write(ws_s *ws, fio_str_info_s msg, uint8_t is_text) {
740
736
  }
741
737
  /** Closes a websocket connection. */
742
738
  void websocket_close(ws_s *ws) {
743
- if (ws->is_client) {
744
- fio_write2(ws->fd, .data.buffer = "\x88\x80MASK", .length = 6,
745
- .after.dealloc = FIO_DEALLOC_NOOP);
746
- } else {
747
- fio_write2(ws->fd, .data.buffer = "\x88\x00", .length = 2,
748
- .after.dealloc = FIO_DEALLOC_NOOP);
749
- }
739
+ fio_write2(ws->fd, .data.buffer = "\x88\x00", .length = 2,
740
+ .after.dealloc = FIO_DEALLOC_NOOP);
750
741
  fio_close(ws->fd);
751
742
  return;
752
743
  }
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = '0.7.58'.freeze
2
+ VERSION = '0.7.60'.freeze
3
3
  end
data/lib/iodine.rb CHANGED
@@ -160,6 +160,10 @@ Iodine.on_state(:before_fork) do
160
160
  ActiveRecord::Base.connection.disconnect!
161
161
  rescue
162
162
  end
163
+ begin
164
+ ActiveRecord::Base.connection_pool.disconnect!
165
+ rescue
166
+ end
163
167
  end
164
168
  if defined?(Sequel)
165
169
  begin
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iodine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.58
4
+ version: 0.7.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-04-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -132,6 +131,7 @@ files:
132
131
  - LIMITS.md
133
132
  - README.md
134
133
  - Rakefile
134
+ - SECURITY.md
135
135
  - SPEC-PubSub-Draft.md
136
136
  - SPEC-WebSocket-Draft.md
137
137
  - bin/console
@@ -251,7 +251,7 @@ licenses:
251
251
  metadata:
252
252
  allowed_push_host: https://rubygems.org
253
253
  post_install_message: |-
254
- Thank you for installing Iodine 0.7.58.
254
+ Thank you for installing Iodine 0.7.60.
255
255
  Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations).
256
256
  rdoc_options: []
257
257
  require_paths:
@@ -274,8 +274,7 @@ requirements:
274
274
  - Ruby >= 2.5.0 recommended.
275
275
  - TLS requires OpenSSL >= 1.1.0.
276
276
  - Or Windows with Ruby >= 3.0.0 build with MingW and MingW as compiler.
277
- rubygems_version: 3.3.26
278
- signing_key:
277
+ rubygems_version: 4.0.3
279
278
  specification_version: 4
280
279
  summary: iodine - a fast HTTP / Websocket Server with Pub/Sub support, optimized for
281
280
  Ruby MRI on Linux / BSD / Windows