iodine 0.4.17 → 0.4.18

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of iodine might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5178eaf9e2ee165e6c1d0dbb166b8c07696152ec5102e897599c16e893171bfe
4
- data.tar.gz: d5bfe18ca14d60aef0d2122ce32f216600b44a51d70295fa929693ac10966f04
3
+ metadata.gz: 985f5c140335dc38ff849e93d96d906a322a22699695908e998c07c8ee023053
4
+ data.tar.gz: a5b55c180aeb05a109c5f150e013b2832fd25f95f29b729488fb150f41aaa8f2
5
5
  SHA512:
6
- metadata.gz: c982ce0213871aca6041636d5091d09522e6485b31b699ce80aed70ad3d9bf13daeca857d89f6f697b73b401f4bee8ca7a7c0aa5e554c13e2785ebcb21f3c198
7
- data.tar.gz: 6a304583f391cbaaa41271277ab291f50c37d34984069e8531cf068d382f2490eaaab4bce488262aa78c8230e6d6cd34e9827500bd5d30bf678fd024d5d55d00
6
+ metadata.gz: 97061042f83574de4992bacb013083e2eb8172fa79ae9ffea146907e53dfd5240f2fa3e91a213e6d87f90601d017fc4f8d2cf0c07726eb8b35b26f7bf82a8615
7
+ data.tar.gz: d9ea0fc7a78a0a4d8d59e391f85a4d228ba0878030a1e97333dee70d7b02a84400f8fc40afbf0a486a71d4fceb1f906cb9a5ed8a4e8da961a3c78c50348654c2
data/CHANGELOG.md CHANGED
@@ -8,9 +8,15 @@ Please notice that this change log contains changes for upcoming releases as wel
8
8
 
9
9
  ---
10
10
 
11
+ #### Change log v.0.4.18
12
+
13
+ **Fix**: (`iodine pub/bus`) fixed issue #27 (?) where the `block` used for subscriptions would be recycled by the GC and the memory address (retained by `iodine`) would point at invalid Ruby objects (at worst) or become invalid (at best). Credit to Dmitry Davydov (@haukot) for exposing this issue.
14
+
15
+ **Fix**: (`facil pub/bus`) fixed issue #27 (?) where the `memcpy` was used instead of `memmove`, resulting in possibly corrupt data in cluster messaging system. Credit to Dmitry Davydov (@haukot) for exposing this issue.
16
+
11
17
  #### Change log v.0.4.17
12
18
 
13
- **Fix**: (`iodine RubyCaller`) fixed issue #26 that exposed an issue in the exception handling logic. This fix enforces exception handling whenever entering the Ruby GVL (GIL), allowing C functions to safely enter the user's Ruby code (where before C functions were assumed to be safe and user code would be executed unprotected when routed through certain functions). Credit to @haukot for exposing this issue (issue #26).
19
+ **Fix**: (`iodine RubyCaller`) fixed issue #26 that exposed an issue in the exception handling logic. This fix enforces exception handling whenever entering the Ruby GVL (GIL), allowing C functions to safely enter the user's Ruby code (where before C functions were assumed to be safe and user code would be executed unprotected when routed through certain functions). Credit to Dmitry Davydov (@haukot) for exposing this issue (issue #26).
14
20
 
15
21
  #### Change log v.0.4.16
16
22
 
data/ext/iodine/facil.c CHANGED
@@ -761,7 +761,7 @@ static void facil_cluster_on_data(intptr_t uuid, protocol_s *pr_) {
761
761
  while (1) {
762
762
  errno = 0;
763
763
  if (pr->read < 8 || pr->read < pr->msg->len) {
764
- ssize_t read = sock_read(uuid, (void *)((uintptr_t)pr->msg + pr->read),
764
+ ssize_t read = sock_read(uuid, (void *)(((uintptr_t)pr->msg) + pr->read),
765
765
  pr->mem_size - pr->read);
766
766
  if (read <= 0) {
767
767
  if (read < 0)
@@ -786,10 +786,13 @@ static void facil_cluster_on_data(intptr_t uuid, protocol_s *pr_) {
786
786
  }
787
787
  }
788
788
  if ((size_t)(pr->msg->len) <= pr->read) {
789
+ const size_t msg_len = (size_t)(pr->msg->len);
790
+ const size_t leftover = (size_t)(pr->read - msg_len);
789
791
  facil_cluster_handle_msg(pr->msg);
790
- pr->read = pr->read - pr->msg->len;
791
- if (pr->read)
792
- memcpy(pr->msg, (void *)((uintptr_t)pr->msg + pr->msg->len), pr->read);
792
+ pr->read = leftover;
793
+ if (leftover) {
794
+ memmove(pr->msg, (void *)(((uintptr_t)pr->msg) + msg_len), pr->read);
795
+ }
793
796
  }
794
797
  }
795
798
  }
@@ -503,17 +503,18 @@ static VALUE iodine_subscribe(VALUE self, VALUE args) {
503
503
  Check_Type(rb_ch, T_STRING);
504
504
 
505
505
  VALUE block = rb_block_proc();
506
+ Registry.add(block);
506
507
 
507
508
  pubsub_engine_s *engine =
508
509
  iodine_engine_ruby2facil(rb_hash_aref(args, engine_varid));
509
510
 
510
- uintptr_t subid = (uintptr_t)
511
- pubsub_subscribe(.channel.name = RSTRING_PTR(rb_ch),
512
- .channel.len = RSTRING_LEN(rb_ch), .engine = engine,
513
- .use_pattern = use_pattern,
514
- .on_message = (block ? on_pubsub_notificationin : NULL),
515
- .on_unsubscribe = (block ? iodine_on_unsubscribe : NULL),
516
- .udata1 = (void *)block);
511
+ uintptr_t subid =
512
+ (uintptr_t)pubsub_subscribe(.channel.name = RSTRING_PTR(rb_ch),
513
+ .channel.len = RSTRING_LEN(rb_ch),
514
+ .engine = engine, .use_pattern = use_pattern,
515
+ .on_message = on_pubsub_notificationin,
516
+ .on_unsubscribe = iodine_on_unsubscribe,
517
+ .udata1 = (void *)block);
517
518
  if (!subid)
518
519
  return Qnil;
519
520
  return ULL2NUM(subid);
data/ext/iodine/pubsub.c CHANGED
@@ -192,15 +192,18 @@ static int pubsub_cluster_publish(struct pubsub_publish_args args) {
192
192
  static void pubsub_cluster_handle_publishing(void *data, uint32_t len) {
193
193
  msg_s *msg = data;
194
194
  if (len != sizeof(*msg) + msg->pub.channel.len + msg->pub.msg.len + 2) {
195
- fprintf(stderr,
196
- "ERROR: (pub/sub) cluster message size error. Message ignored.\n");
195
+ fprintf(
196
+ stderr,
197
+ "ERROR: (pub/sub) cluster message size error. Message ignored.\n"
198
+ " expecting %zu (ch: %zu, msg: %zu), got %zu\n",
199
+ (size_t)(sizeof(*msg) + msg->pub.channel.len + msg->pub.msg.len + 2),
200
+ (size_t)msg->pub.channel.len, (size_t)msg->pub.msg.len, (size_t)len);
197
201
  return;
198
202
  }
199
203
  msg = malloc(len);
200
204
  if (!msg) {
201
- fprintf(
202
- stderr,
203
- "ERROR: (pub/sub) cluster message allocation error.Message ignored.\n");
205
+ fprintf(stderr, "ERROR: (pub/sub) cluster message allocation error. "
206
+ "Message ignored.\n");
204
207
  return;
205
208
  }
206
209
  memcpy(msg, data, len);
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = '0.4.17'.freeze
2
+ VERSION = '0.4.18'.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.4.17
4
+ version: 0.4.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-10 00:00:00.000000000 Z
11
+ date: 2018-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack