rbczmq 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTIyYzk0ZmFkOTc4Y2YwMmRlYzc3ZGE0NmQyZTBhOGRlODQyMDcxMA==
4
+ MTYzNjRlZGJiYTMyN2NhZDQ4OTM4MmRjMzEzODM4NjIzYzA2NTE2Mw==
5
5
  data.tar.gz: !binary |-
6
- NTI4NzQyMDhkNGRjNGE5NDgxMDE3ZDg5MjU2YTViZWZiMWNjYzQxZA==
6
+ YTNmNWY3NzBhMDRlOWI4MGFkNjc5NTVlZDFkY2RhMjRhMTZhM2QyMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZmQ5NzExNWFhM2ZiODBlZmY4ZDZkMmM5YjBjMDQxODNkZDFlNTUxZmZlMjIz
10
- N2JkZGU0Mjg4NzJlZTM2ZTEzYjI5ZDdkMGExNDU5MGMzMDE1ZjM2OTUxOTk4
11
- ZDAyYjcwNTcyOGUzYjNhOTFkYzYyZTM5NTBkNjgyNDgyN2Q0ZDg=
9
+ MjRiOTYyZTlmNjY0NzVlYjdmYzNiZjZjZWVmMWZiYmUyYmJlZmNhZTYwYjky
10
+ MjM0OTFmMzAxMjA4ZDBkMDM5ZGUyYTg3ZjYwYTk2OTIzOTAxMzA2MjI3NWJm
11
+ YjAxNGJiN2M0MDAzNzQyYTMyMWFmY2MxYzQ1MDRmODI4OTI3Njg=
12
12
  data.tar.gz: !binary |-
13
- NDJmOGNmNmMwNGM3YjY5NmUwYTZmOTYzNzAyNGU5YzFmMTc0NGRhYTUzYjIw
14
- YzI0YjJiODBlMjliMGQyYThjNjFhMWE1MWExZTJhNjAzNTMyNjQzZTM2YWZk
15
- M2NiYzc5Mzc0NGE0NjlkMmQ1YzBmYTMyYjdiZjkxNmFkMGE5ZTI=
13
+ NWFjYzEyNDU2OTBmMjM2NjFmY2Y1MzY3MjhhNjIzMTdiMDkwZTgzYjYyNjlj
14
+ OGRmNzEyY2QyMzczMDhhZWIyY2I0NmViNGNjOTY0MjYwM2UwYTA0ZjMxOTI4
15
+ NWI2YmJjNjFmNWI5NTQwOWU3Mzc0NmVjYTkyZTEzZGM2MDlkNWM=
@@ -1,5 +1,12 @@
1
1
  = Changelog
2
2
 
3
+ == 1.7.1 (July 25, 2013)
4
+
5
+ * FIX: ZMQ::Message#pop did not relase ownership of frame.
6
+ * FIX: !Important! ZMQ::Message was not marking owned ZMQ::Frame objects, leading to potential GC crash in 1.7.0.
7
+ * FIX: Fixed memory leak in ZMQ::Message.
8
+ * Updated license in gemspec and readme.
9
+
3
10
  == 1.7.0 (July 21, 2013)
4
11
 
5
12
  * ZMQ::Frame - Implemented an interal wrapper around the underlying czmq frame objects to better manage memory and object ownership. (Matt Connolly)
@@ -232,6 +232,11 @@ You can get those with brew packaging system:
232
232
 
233
233
  brew install libtool autoconf automake
234
234
 
235
+ == LICENSE
236
+
237
+ The rbczmq gem is licensed under the MIT license. See the file "MIT-LICENSE" for details.
238
+ This gem uses the "zmq" and "czmq" libraries, both of which are licensed under the LGPL license.
239
+
235
240
  == TODO
236
241
 
237
242
  * ZMQ::Message#save && ZMQ::Message.load
@@ -28,10 +28,11 @@ VALUE rb_czmq_alloc_frame(zframe_t *frame)
28
28
  */
29
29
  void rb_czmq_free_frame(zmq_frame_wrapper *frame)
30
30
  {
31
- if (frame && frame->frame && (frame->flags & ZMQ_FRAME_OWNED) != 0) {
31
+ if (frame->frame && (frame->flags & ZMQ_FRAME_OWNED) != 0) {
32
32
  zframe_destroy(&frame->frame);
33
33
  frame->flags &= ~ZMQ_FRAME_OWNED;
34
34
  }
35
+ frame->frame = NULL;
35
36
  }
36
37
 
37
38
  /*
@@ -42,7 +43,10 @@ void rb_czmq_free_frame(zmq_frame_wrapper *frame)
42
43
  void rb_czmq_free_frame_gc(void *ptr)
43
44
  {
44
45
  zmq_frame_wrapper *frame = (zmq_frame_wrapper *)ptr;
45
- rb_czmq_free_frame(frame);
46
+ if (frame) {
47
+ rb_czmq_free_frame(frame);
48
+ xfree(frame);
49
+ }
46
50
  }
47
51
 
48
52
  /*
@@ -8,10 +8,14 @@
8
8
  void rb_czmq_free_message(zmq_message_wrapper *message)
9
9
  {
10
10
  errno = 0;
11
- if (message != NULL && message->message != NULL && message->flags & ZMQ_MESSAGE_OWNED) {
11
+
12
+ if (message->message != NULL && message->flags & ZMQ_MESSAGE_OWNED) {
12
13
  zmsg_destroy(&message->message);
13
- message->message = NULL;
14
14
  message->flags &= ~ZMQ_MESSAGE_OWNED;
15
+ }
16
+ message->message = NULL;
17
+
18
+ if (message->frames) {
15
19
  zlist_destroy(&message->frames);
16
20
  }
17
21
  }
@@ -36,10 +40,12 @@ static void rb_czmq_free_message_gc(void *ptr)
36
40
  */
37
41
  void rb_czmq_mark_message(zmq_message_wrapper *message)
38
42
  {
39
- VALUE frame = (VALUE)zlist_first(message->frames);
40
- while (frame) {
41
- rb_gc_mark(frame);
42
- frame = (VALUE)zlist_next(message->frames);
43
+ if (message->frames) {
44
+ VALUE frame = (VALUE)zlist_first(message->frames);
45
+ while (frame) {
46
+ rb_gc_mark(frame);
47
+ frame = (VALUE)zlist_next(message->frames);
48
+ }
43
49
  }
44
50
  }
45
51
 
@@ -53,7 +59,7 @@ VALUE rb_czmq_alloc_message(zmsg_t *message)
53
59
  VALUE message_obj;
54
60
  zmq_message_wrapper *m = NULL;
55
61
  errno = 0;
56
- message_obj = Data_Make_Struct(rb_cZmqMessage, zmq_message_wrapper, 0, rb_czmq_free_message_gc, m);
62
+ message_obj = Data_Make_Struct(rb_cZmqMessage, zmq_message_wrapper, rb_czmq_mark_message, rb_czmq_free_message_gc, m);
57
63
  m->message = message;
58
64
  ZmqAssertObjOnAlloc(m->message, m);
59
65
  m->flags = ZMQ_MESSAGE_OWNED;
@@ -217,12 +223,16 @@ static VALUE rb_czmq_message_add(VALUE obj, VALUE frame_obj)
217
223
 
218
224
  static VALUE rb_czmq_message_pop(VALUE obj)
219
225
  {
220
- zframe_t *frame = NULL;
226
+ zframe_t *zframe = NULL;
221
227
  ZmqGetMessage(obj);
222
228
  ZmqAssertMessageOwned(message);
223
- frame = zmsg_pop(message->message); /* we now own the frame */
224
- if (frame == NULL) return Qnil;
229
+ zframe = zmsg_pop(message->message); /* we now own the frame */
230
+ if (zframe == NULL) return Qnil;
225
231
  VALUE frame_obj = (VALUE)zlist_pop(message->frames);
232
+ /* detach frame from message, it is now owned by the ruby object */
233
+ ZmqGetFrame(frame_obj);
234
+ frame->flags |= ZMQ_FRAME_OWNED;
235
+ frame->message = NULL;
226
236
  return frame_obj ? frame_obj : Qnil;
227
237
  }
228
238
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module ZMQ
4
- VERSION = "1.7.0"
4
+ VERSION = "1.7.1"
5
5
  end
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.authors = ["Lourens Naudé", "James Tucker", "Matt Connolly"]
11
11
  s.email = ["lourens@methodmissing.com", "jftucker@gmail.com", "matt.connolly@me.com"]
12
12
  s.homepage = "http://github.com/methodmissing/rbczmq"
13
+ s.license = 'MIT'
13
14
  s.date = Time.now.utc.strftime('%Y-%m-%d')
14
15
  s.platform = Gem::Platform::RUBY
15
16
  s.extensions = "ext/rbczmq/extconf.rb"
@@ -291,4 +291,14 @@ class TestZmqMessage < ZmqTestCase
291
291
  ensure
292
292
  ctx.destroy
293
293
  end
294
+
295
+ def test_pop_ownership
296
+ msg = ZMQ::Message.new
297
+ other = ZMQ::Message.new
298
+ msg.pushstr "hello"
299
+ frame = msg.pop
300
+ other.push frame
301
+ assert_equal 1, other.size
302
+ end
303
+
294
304
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbczmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lourens Naudé
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-07-21 00:00:00.000000000 Z
13
+ date: 2013-07-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake-compiler
@@ -527,7 +527,8 @@ files:
527
527
  - ext/zeromq/tests/testutil.hpp
528
528
  - ext/zeromq/version.sh
529
529
  homepage: http://github.com/methodmissing/rbczmq
530
- licenses: []
530
+ licenses:
531
+ - MIT
531
532
  metadata: {}
532
533
  post_install_message:
533
534
  rdoc_options: