iodine 0.7.48 → 0.7.49

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1718fc25cba1ab9a96c643a16e34413067b30b6706659ca77becf907a92bafe6
4
- data.tar.gz: 1b3fc0945e54e6eedf7e1fa27956cecfe46e80c8a43078f305343a9eb3497f50
3
+ metadata.gz: 1dad2816193abeda90adf195c3c9cfcaa53eb9a1c5f1e4ad8364be45cd10bc2f
4
+ data.tar.gz: 02e35b8bbdf6516d210bd8cfc012035a1de2ec3a783e4346152bead0186ba668
5
5
  SHA512:
6
- metadata.gz: 70945896acf5a4497254bd631bcc427bde4051813c65d44d43567c0283a40c61a1ecefa547985ee481981a21e4bcf4d3380076fbc5816eed2fdc06a487553e64
7
- data.tar.gz: bfba77e38f598db62a893ad356ad40485a9dfc768355357bc8242227991ecf8c24354f2f30e52d3afcf1d8f1c62b0fec15c7a2baec309c5b29d6b042918ff259
6
+ metadata.gz: bca7fb5be56837c4a729cef3f755ee4fa8a5a289d448961e01f9449a6e3d76865b03956d7525802a2a1c3768da61b4b8cf8a6088ca63ed57e3b966575e95fb51
7
+ data.tar.gz: f2fcb35e2cd7452dbeb7fb20bbe5deb3f661e8a3f3ec387d878a858732a414d3d383320164a8a3164be0cdebf900a14360e60d87488c5d61e5b8105ada6270d8
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ Please notice that this change log contains changes for upcoming releases as wel
6
6
 
7
7
  ## Changes:
8
8
 
9
+ #### Change log v.0.7.49
10
+
11
+ **Fix**: Fixes an issue where named arguments for `subscribe` might not be properly recognized.
12
+
9
13
  #### Change log v.0.7.48 (2022-06-28)
10
14
 
11
15
  **Fix**: Fixes an issue with `pong` WebSocket frames when a client sends a WebSocket `ping`. Credit to Lucas Kuan (@lucaskuan) for finding this issue and for PR #124.
data/examples/config.ru CHANGED
@@ -12,6 +12,9 @@
12
12
  #
13
13
  # ab -c 2000 -t 5 -n 1000000 -k http://127.0.0.1:3000/
14
14
  # wrk -c2000 -d5 -t12 http://localhost:3000/
15
+ #
16
+ # Test websocket echo using the browser. For example:
17
+ # ws = new WebSocket("ws://localhost:3000"); ws.onmessage = function(e) {console.log("Got message!"); console.log(e.data);}; ws.onclose = function(e) {console.log("closed")}; ws.onopen = function(e) {ws.send("hi");};
15
18
 
16
19
 
17
20
  # A simple router - Checks for Websocket Upgrade and answers HTTP.
data/ext/iodine/fio.c CHANGED
@@ -3689,7 +3689,8 @@ closed:
3689
3689
  return -1;
3690
3690
 
3691
3691
  flush_rw_hook:
3692
- flushed = uuid_data(uuid).rw_hooks->flush(uuid, uuid_data(uuid).rw_udata);
3692
+ if(uuid_data(uuid).rw_hooks)
3693
+ flushed = uuid_data(uuid).rw_hooks->flush(uuid, uuid_data(uuid).rw_udata);
3693
3694
  fio_unlock(&uuid_data(uuid).sock_lock);
3694
3695
  if (!flushed)
3695
3696
  return 0;
@@ -3749,7 +3750,8 @@ size_t fio_flush_all(void) {
3749
3750
  return 0;
3750
3751
  size_t count = 0;
3751
3752
  for (uintptr_t i = 0; i <= fio_data->max_protocol_fd; ++i) {
3752
- if ((fd_data(i).open || fd_data(i).packet) && fio_flush(fd2uuid(i)) > 0)
3753
+ if ((fd_data(i).open || fd_data(i).packet) &&
3754
+ fd_data(i).rw_hooks && fio_flush(fd2uuid(i)) > 0)
3753
3755
  ++count;
3754
3756
  }
3755
3757
  return count;
@@ -518,10 +518,10 @@ static iodine_sub_args_s iodine_subscribe_args(int argc, VALUE *argv) {
518
518
  /* single argument must be a Hash / channel name */
519
519
  if (TYPE(argv[0]) == T_HASH) {
520
520
  rb_opt = argv[0];
521
- ret.channel = rb_hash_aref(argv[0], to_id);
521
+ ret.channel = rb_hash_aref(argv[0], ID2SYM(to_id));
522
522
  if (ret.channel == Qnil || ret.channel == Qfalse) {
523
523
  /* temporary backport support */
524
- ret.channel = rb_hash_aref(argv[0], channel_id);
524
+ ret.channel = rb_hash_aref(argv[0], ID2SYM(channel_id));
525
525
  if (ret.channel != Qnil) {
526
526
  FIO_LOG_WARNING("use of :channel in subscribe is deprecated.");
527
527
  }
@@ -546,13 +546,16 @@ static iodine_sub_args_s iodine_subscribe_args(int argc, VALUE *argv) {
546
546
  Check_Type(ret.channel, T_STRING);
547
547
 
548
548
  if (rb_opt) {
549
- if (rb_hash_aref(rb_opt, as_id) == binary_id) {
549
+ VALUE tmp = Qnil;
550
+ if ((tmp = rb_hash_aref(rb_opt, ID2SYM(as_id))) != Qnil &&
551
+ TYPE(tmp) == T_SYMBOL && rb_sym2id(tmp) == binary_id) {
550
552
  ret.binary = 1;
551
553
  }
552
- if (rb_hash_aref(rb_opt, match_id) == redis_id) {
554
+ if ((tmp = rb_hash_aref(rb_opt, ID2SYM(match_id))) != Qnil &&
555
+ TYPE(tmp) == T_SYMBOL && rb_sym2id(tmp) == redis_id) {
553
556
  ret.pattern = FIO_MATCH_GLOB;
554
557
  }
555
- ret.block = rb_hash_aref(rb_opt, handler_id);
558
+ ret.block = rb_hash_aref(rb_opt, ID2SYM(handler_id));
556
559
  if (ret.block != Qnil) {
557
560
  IodineStore.add(ret.block);
558
561
  }
@@ -453,6 +453,7 @@ static uint64_t websocket_consume(void *buffer, uint64_t len, void *udata,
453
453
  fprintf(stderr, "ERROR: WebSocket protocol error - unmasked data.\n");
454
454
  #endif
455
455
  websocket_on_protocol_error(udata);
456
+ return 0;
456
457
  }
457
458
  /* call callback */
458
459
  switch (pos[0] & 15) {
@@ -127,6 +127,8 @@ struct ws_s {
127
127
  struct buffer_s buffer;
128
128
  /** data length (how much of the buffer actually used). */
129
129
  size_t length;
130
+ /** total data length (including continuation frames). */
131
+ size_t total_length;
130
132
  /** message buffer. */
131
133
  FIOBJ msg;
132
134
  /** latest text state. */
@@ -155,20 +157,24 @@ static void websocket_on_unwrapped(void *ws_p, void *msg, uint64_t len,
155
157
  char first, char last, char text,
156
158
  unsigned char rsv) {
157
159
  ws_s *ws = ws_p;
160
+ if (!ws)
161
+ return;
158
162
  if (last && first) {
159
163
  ws->on_message(ws, (fio_str_info_s){.data = msg, .len = len},
160
164
  (uint8_t)text);
161
165
  return;
162
166
  }
167
+ if (ws->msg == FIOBJ_INVALID)
168
+ ws->msg = fiobj_str_buf(len);
169
+ ws->total_length += len;
163
170
  if (first) {
164
171
  ws->is_text = (uint8_t)text;
165
- if (ws->msg == FIOBJ_INVALID)
166
- ws->msg = fiobj_str_buf(len);
167
- fiobj_str_resize(ws->msg, 0);
168
172
  }
169
173
  fiobj_str_write(ws->msg, msg, len);
170
174
  if (last) {
171
175
  ws->on_message(ws, fiobj_obj2cstr(ws->msg), ws->is_text);
176
+ fiobj_str_resize(ws->msg, 0);
177
+ ws->total_length = 0;
172
178
  }
173
179
 
174
180
  (void)rsv;
@@ -261,7 +267,7 @@ static void on_data(intptr_t sockfd, fio_protocol_s *ws_) {
261
267
  websocket_buffer_peek(ws->buffer.data, ws->length);
262
268
  const uint64_t raw_length = info.packet_length + info.head_length;
263
269
  /* test expected data amount */
264
- if (ws->max_msg_size < raw_length) {
270
+ if (ws->max_msg_size < raw_length + ws->total_length) {
265
271
  /* too big */
266
272
  websocket_close(ws);
267
273
  return;
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = '0.7.48'.freeze
2
+ VERSION = '0.7.49'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iodine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.48
4
+ version: 0.7.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-28 00:00:00.000000000 Z
11
+ date: 2022-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -245,7 +245,7 @@ licenses:
245
245
  metadata:
246
246
  allowed_push_host: https://rubygems.org
247
247
  post_install_message: |-
248
- Thank you for installing Iodine 0.7.48.
248
+ Thank you for installing Iodine 0.7.49.
249
249
  Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations).
250
250
  rdoc_options: []
251
251
  require_paths: