rbczmq 1.7.2 → 1.7.3

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.
@@ -210,6 +210,19 @@ static void rb_czmq_free_loop_gc(void *ptr)
210
210
  }
211
211
  }
212
212
 
213
+ /*
214
+ * :nodoc:
215
+ * GC mark callback
216
+ *
217
+ */
218
+ static void rb_czmq_mark_loop(void *ptr)
219
+ {
220
+ zmq_loop_wrapper *loop = (zmq_loop_wrapper *)ptr;
221
+ if (loop) {
222
+ rb_gc_mark(loop->items);
223
+ }
224
+ }
225
+
213
226
  /*
214
227
  * call-seq:
215
228
  * ZMQ::Loop.new => ZMQ::Loop
@@ -225,12 +238,13 @@ static VALUE rb_czmq_loop_new(VALUE loop)
225
238
  {
226
239
  zmq_loop_wrapper *lp = NULL;
227
240
  errno = 0;
228
- loop = Data_Make_Struct(rb_cZmqLoop, zmq_loop_wrapper, 0, rb_czmq_free_loop_gc, lp);
241
+ loop = Data_Make_Struct(rb_cZmqLoop, zmq_loop_wrapper, rb_czmq_mark_loop, rb_czmq_free_loop_gc, lp);
229
242
  lp->loop = zloop_new();
230
243
  ZmqAssertObjOnAlloc(lp->loop, lp);
231
244
  lp->flags = 0;
232
245
  lp->running = false;
233
246
  lp->verbose = false;
247
+ lp->items = rb_ary_new();
234
248
  rb_obj_call_init(loop, 0, NULL);
235
249
  return loop;
236
250
  }
@@ -394,7 +408,7 @@ static VALUE rb_czmq_loop_set_verbose(VALUE obj, VALUE level)
394
408
  * === Examples
395
409
  * loop = ZMQ::Loop.new => ZMQ::Loop
396
410
  * item = ZMQ::Pollitem.new(sock, ZMQ::POLLIN) => ZMQ::Pollitem
397
- * loop.register(item) => true
411
+ * loop.register(item) => ZMQ::Pollitem (coerced)
398
412
  *
399
413
  */
400
414
 
@@ -405,11 +419,12 @@ static VALUE rb_czmq_loop_register(VALUE obj, VALUE pollable)
405
419
  ZmqGetLoop(obj);
406
420
  pollable = rb_czmq_pollitem_coerce(pollable);
407
421
  ZmqGetPollitem(pollable);
422
+ rb_ary_push(loop->items, pollable);
408
423
  rc = zloop_poller(loop->loop, pollitem->item, rb_czmq_loop_pollitem_callback, (void *)pollitem);
409
424
  ZmqAssert(rc);
410
425
  /* Let pollable be verbose if loop is verbose */
411
426
  if (loop->verbose == true) rb_czmq_pollitem_set_verbose(pollable, Qtrue);
412
- return Qtrue;
427
+ return pollable;
413
428
  }
414
429
 
415
430
  /*
@@ -433,6 +448,7 @@ static VALUE rb_czmq_loop_remove(VALUE obj, VALUE pollable)
433
448
  pollable = rb_czmq_pollitem_coerce(pollable);
434
449
  ZmqGetPollitem(pollable);
435
450
  zloop_poller_end(loop->loop, pollitem->item);
451
+ rb_ary_delete(loop->items, pollable);
436
452
  return Qnil;
437
453
  }
438
454
 
@@ -456,6 +472,7 @@ static VALUE rb_czmq_loop_register_timer(VALUE obj, VALUE tm)
456
472
  ZmqGetLoop(obj);
457
473
  ZmqGetTimer(tm);
458
474
  rc = zloop_timer(loop->loop, timer->delay, timer->times, rb_czmq_loop_timer_callback, (void *)tm);
475
+ rb_ary_push(loop->items, tm);
459
476
  ZmqAssert(rc);
460
477
  return Qtrue;
461
478
  }
@@ -481,6 +498,7 @@ static VALUE rb_czmq_loop_cancel_timer(VALUE obj, VALUE tm)
481
498
  ZmqGetLoop(obj);
482
499
  ZmqGetTimer(tm);
483
500
  rc = zloop_timer_end(loop->loop, (void *)tm);
501
+ rb_ary_delete(loop->items, tm);
484
502
  ZmqAssert(rc);
485
503
  return Qtrue;
486
504
  }
@@ -8,6 +8,7 @@ typedef struct {
8
8
  int flags;
9
9
  bool verbose;
10
10
  bool running;
11
+ VALUE items; /* pollitem and timer objects we need to keep from being garbage collected. */
11
12
  } zmq_loop_wrapper;
12
13
 
13
14
  #define ZmqAssertLoop(obj) ZmqAssertType(obj, rb_cZmqLoop, "ZMQ::Loop")
@@ -1,5 +1,45 @@
1
- 0MQ version 4.1.0, released on 2014/xx/xx
2
- =========================================
1
+ 0MQ version 4.0.1 stable, released on 2013/10/08
2
+ ================================================
3
+
4
+ Changes
5
+ -------
6
+
7
+ * Updated CURVE mechanism to track revised RFC 27 (INITIATE vouch).
8
+
9
+ The INITIATE command vouch box is Box[C',S](C->S') instead of
10
+ Box[C'](C->S), to reduce the risk of client impersonation, as per
11
+ https://codesinchaos.wordpress.com/2012/09/09/curvecp-1/.
12
+
13
+ * Fixed LIBZMQ-567, adding abstract namespaces for IPC sockets on Linux.
14
+
15
+ Converts an initial strudel or "at sign" (@) in the Unix socket path to
16
+ a NULL character ('\0') indicating that the socket uses the abstract
17
+ namespace instead of the filesystem namespace. For instance, binding a
18
+ socket to 'ipc://@/tmp/tester' will not create a file associated with
19
+ the socket whereas binding to 'ipc:///tmp/tester' will create the file
20
+ /tmp/tester. See issue 567 for more information.
21
+
22
+ * Added zmq_z85_encode and zmq_z85_decode to core libzmq API.
23
+
24
+ * Added zmq_curve_keypair to core libzmq API.
25
+
26
+ * Replaced macro constants in zmq.h with enum types for user-facing
27
+ constants (except ZMQ version numbers).
28
+
29
+ * Bumped library ABI version to 4:0:1.
30
+
31
+ Bug fixes
32
+ ---------
33
+
34
+ * Fixed some build/test errors on OS/X + Clang++.
35
+
36
+ * Fixed LIBZMQ-565, typo in code.
37
+
38
+ * Fixed LIBZMQ-566, dealer-to-router connections sometimes failing.
39
+
40
+ * Fixed builds for AIX, MSVC 2008, OS/X with clang++, Solaris.
41
+
42
+ * Improved CURVE handshake error handling.
3
43
 
4
44
 
5
45
  0MQ version 4.0.0 (RC1), released on 2013/09/20
@@ -48,6 +48,11 @@ NOTE: the endpoint pathname must be writable by the process. When the endpoint
48
48
  starts with '/', e.g., `ipc:///pathname`, this will be an _absolute_ pathname.
49
49
  If the endpoint specifies a directory that does not exist, the bind shall fail.
50
50
 
51
+ NOTE: on Linux only, when the endpoint pathname starts with `@`, the abstract
52
+ namespace shall be used. The abstract namespace is independent of the
53
+ filesystem and if a process attempts to bind an endpoint already bound by a
54
+ process, it will fail. See unix(7) for details.
55
+
51
56
  Connecting a socket
52
57
  ~~~~~~~~~~~~~~~~~~~
53
58
  When connecting a 'socket' to a peer address using _zmq_connect()_ with the
@@ -84,8 +84,8 @@ typedef unsigned __int8 uint8_t;
84
84
 
85
85
  /* Version macros for compile-time API version detection */
86
86
  #define ZMQ_VERSION_MAJOR 4
87
- #define ZMQ_VERSION_MINOR 1
88
- #define ZMQ_VERSION_PATCH 0
87
+ #define ZMQ_VERSION_MINOR 0
88
+ #define ZMQ_VERSION_PATCH 1
89
89
 
90
90
  #define ZMQ_MAKE_VERSION(major, minor, patch) \
91
91
  ((major) * 10000 + (minor) * 100 + (patch))
@@ -179,18 +179,13 @@ ZMQ_EXPORT const char *zmq_strerror (int errnum);
179
179
  /******************************************************************************/
180
180
 
181
181
  /* New API */
182
+ /* Context options */
183
+ #define ZMQ_IO_THREADS 1
184
+ #define ZMQ_MAX_SOCKETS 2
182
185
 
183
- enum zmq_ctx_opts_t {
184
- /* Context options */
185
- ZMQ_IO_THREADS = 1,
186
- ZMQ_MAX_SOCKETS = 2
187
- };
188
-
189
- enum zmq_ctx_defaults_t {
190
- /* Default for new contexts */
191
- ZMQ_IO_THREADS_DFLT = 1,
192
- ZMQ_MAX_SOCKETS_DFLT = 1024
193
- };
186
+ /* Default for new contexts */
187
+ #define ZMQ_IO_THREADS_DFLT 1
188
+ #define ZMQ_MAX_SOCKETS_DFLT 1024
194
189
 
195
190
  ZMQ_EXPORT void *zmq_ctx_new (void);
196
191
  ZMQ_EXPORT int zmq_ctx_term (void *context);
@@ -233,110 +228,109 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
233
228
  /******************************************************************************/
234
229
 
235
230
  /* Socket types. */
236
- enum zmq_socket_types_t {
237
- ZMQ_PAIR = 0,
238
- ZMQ_PUB = 1,
239
- ZMQ_SUB = 2,
240
- ZMQ_REQ = 3,
241
- ZMQ_REP = 4,
242
- ZMQ_DEALER = 5,
243
- ZMQ_ROUTER = 6,
244
- ZMQ_PULL = 7,
245
- ZMQ_PUSH = 8,
246
- ZMQ_XPUB = 9,
247
- ZMQ_XSUB = 10,
248
- ZMQ_STREAM = 11
249
- };
231
+ #define ZMQ_PAIR 0
232
+ #define ZMQ_PUB 1
233
+ #define ZMQ_SUB 2
234
+ #define ZMQ_REQ 3
235
+ #define ZMQ_REP 4
236
+ #define ZMQ_DEALER 5
237
+ #define ZMQ_ROUTER 6
238
+ #define ZMQ_PULL 7
239
+ #define ZMQ_PUSH 8
240
+ #define ZMQ_XPUB 9
241
+ #define ZMQ_XSUB 10
242
+ #define ZMQ_STREAM 11
243
+
244
+ /* Deprecated aliases */
245
+ #define ZMQ_XREQ ZMQ_DEALER
246
+ #define ZMQ_XREP ZMQ_ROUTER
250
247
 
251
248
  /* Socket options. */
252
- enum zmq_socket_opts_t {
253
- ZMQ_AFFINITY = 4,
254
- ZMQ_IDENTITY = 5,
255
- ZMQ_SUBSCRIBE = 6,
256
- ZMQ_UNSUBSCRIBE = 7,
257
- ZMQ_RATE = 8,
258
- ZMQ_RECOVERY_IVL = 9,
259
- ZMQ_SNDBUF = 11,
260
- ZMQ_RCVBUF = 12,
261
- ZMQ_RCVMORE = 13,
262
- ZMQ_FD = 14,
263
- ZMQ_EVENTS = 15,
264
- ZMQ_TYPE = 16,
265
- ZMQ_LINGER = 17,
266
- ZMQ_RECONNECT_IVL = 18,
267
- ZMQ_BACKLOG = 19,
268
- ZMQ_RECONNECT_IVL_MAX = 21,
269
- ZMQ_MAXMSGSIZE = 22,
270
- ZMQ_SNDHWM = 23,
271
- ZMQ_RCVHWM = 24,
272
- ZMQ_MULTICAST_HOPS = 25,
273
- ZMQ_RCVTIMEO = 27,
274
- ZMQ_SNDTIMEO = 28,
275
- ZMQ_LAST_ENDPOINT = 32,
276
- ZMQ_ROUTER_MANDATORY = 33,
277
- ZMQ_TCP_KEEPALIVE = 34,
278
- ZMQ_TCP_KEEPALIVE_CNT = 35,
279
- ZMQ_TCP_KEEPALIVE_IDLE = 36,
280
- ZMQ_TCP_KEEPALIVE_INTVL = 37,
281
- ZMQ_TCP_ACCEPT_FILTER = 38,
282
- ZMQ_IMMEDIATE = 39,
283
- ZMQ_XPUB_VERBOSE = 40,
284
- ZMQ_ROUTER_RAW = 41,
285
- ZMQ_IPV6 = 42,
286
- ZMQ_MECHANISM = 43,
287
- ZMQ_PLAIN_SERVER = 44,
288
- ZMQ_PLAIN_USERNAME = 45,
289
- ZMQ_PLAIN_PASSWORD = 46,
290
- ZMQ_CURVE_SERVER = 47,
291
- ZMQ_CURVE_PUBLICKEY = 48,
292
- ZMQ_CURVE_SECRETKEY = 49,
293
- ZMQ_CURVE_SERVERKEY = 50,
294
- ZMQ_PROBE_ROUTER = 51,
295
- ZMQ_REQ_CORRELATE = 52,
296
- ZMQ_REQ_RELAXED = 53,
297
- ZMQ_CONFLATE = 54,
298
- ZMQ_ZAP_DOMAIN = 55
299
- };
249
+ #define ZMQ_AFFINITY 4
250
+ #define ZMQ_IDENTITY 5
251
+ #define ZMQ_SUBSCRIBE 6
252
+ #define ZMQ_UNSUBSCRIBE 7
253
+ #define ZMQ_RATE 8
254
+ #define ZMQ_RECOVERY_IVL 9
255
+ #define ZMQ_SNDBUF 11
256
+ #define ZMQ_RCVBUF 12
257
+ #define ZMQ_RCVMORE 13
258
+ #define ZMQ_FD 14
259
+ #define ZMQ_EVENTS 15
260
+ #define ZMQ_TYPE 16
261
+ #define ZMQ_LINGER 17
262
+ #define ZMQ_RECONNECT_IVL 18
263
+ #define ZMQ_BACKLOG 19
264
+ #define ZMQ_RECONNECT_IVL_MAX 21
265
+ #define ZMQ_MAXMSGSIZE 22
266
+ #define ZMQ_SNDHWM 23
267
+ #define ZMQ_RCVHWM 24
268
+ #define ZMQ_MULTICAST_HOPS 25
269
+ #define ZMQ_RCVTIMEO 27
270
+ #define ZMQ_SNDTIMEO 28
271
+ #define ZMQ_LAST_ENDPOINT 32
272
+ #define ZMQ_ROUTER_MANDATORY 33
273
+ #define ZMQ_TCP_KEEPALIVE 34
274
+ #define ZMQ_TCP_KEEPALIVE_CNT 35
275
+ #define ZMQ_TCP_KEEPALIVE_IDLE 36
276
+ #define ZMQ_TCP_KEEPALIVE_INTVL 37
277
+ #define ZMQ_TCP_ACCEPT_FILTER 38
278
+ #define ZMQ_IMMEDIATE 39
279
+ #define ZMQ_XPUB_VERBOSE 40
280
+ #define ZMQ_ROUTER_RAW 41
281
+ #define ZMQ_IPV6 42
282
+ #define ZMQ_MECHANISM 43
283
+ #define ZMQ_PLAIN_SERVER 44
284
+ #define ZMQ_PLAIN_USERNAME 45
285
+ #define ZMQ_PLAIN_PASSWORD 46
286
+ #define ZMQ_CURVE_SERVER 47
287
+ #define ZMQ_CURVE_PUBLICKEY 48
288
+ #define ZMQ_CURVE_SECRETKEY 49
289
+ #define ZMQ_CURVE_SERVERKEY 50
290
+ #define ZMQ_PROBE_ROUTER 51
291
+ #define ZMQ_REQ_CORRELATE 52
292
+ #define ZMQ_REQ_RELAXED 53
293
+ #define ZMQ_CONFLATE 54
294
+ #define ZMQ_ZAP_DOMAIN 55
300
295
 
301
296
  /* Message options */
302
- enum zmq_msg_opts_t {
303
- ZMQ_MORE = 1
304
- };
297
+ #define ZMQ_MORE 1
305
298
 
306
299
  /* Send/recv options. */
307
- enum zmq_send_recv_opts_t {
308
- ZMQ_DONTWAIT = 1,
309
- ZMQ_SNDMORE = 2
310
- };
300
+ #define ZMQ_DONTWAIT 1
301
+ #define ZMQ_SNDMORE 2
311
302
 
312
303
  /* Security mechanisms */
313
- enum zmq_security_types_t {
314
- ZMQ_NULL = 0,
315
- ZMQ_PLAIN = 1,
316
- ZMQ_CURVE = 2
317
- };
304
+ #define ZMQ_NULL 0
305
+ #define ZMQ_PLAIN 1
306
+ #define ZMQ_CURVE 2
307
+
308
+ /* Deprecated options and aliases */
309
+ #define ZMQ_IPV4ONLY 31
310
+ #define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE
311
+ #define ZMQ_NOBLOCK ZMQ_DONTWAIT
312
+ #define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY
313
+ #define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY
318
314
 
319
315
  /******************************************************************************/
320
316
  /* 0MQ socket events and monitoring */
321
317
  /******************************************************************************/
322
318
 
323
319
  /* Socket transport events (tcp and ipc only) */
324
- enum zmq_transport_events_t {
325
- ZMQ_EVENT_CONNECTED = 1,
326
- ZMQ_EVENT_CONNECT_DELAYED = 2,
327
- ZMQ_EVENT_CONNECT_RETRIED = 4,
320
+ #define ZMQ_EVENT_CONNECTED 1
321
+ #define ZMQ_EVENT_CONNECT_DELAYED 2
322
+ #define ZMQ_EVENT_CONNECT_RETRIED 4
328
323
 
329
- ZMQ_EVENT_LISTENING = 8,
330
- ZMQ_EVENT_BIND_FAILED = 16,
324
+ #define ZMQ_EVENT_LISTENING 8
325
+ #define ZMQ_EVENT_BIND_FAILED 16
331
326
 
332
- ZMQ_EVENT_ACCEPTED = 32,
333
- ZMQ_EVENT_ACCEPT_FAILED = 64,
327
+ #define ZMQ_EVENT_ACCEPTED 32
328
+ #define ZMQ_EVENT_ACCEPT_FAILED 64
334
329
 
335
- ZMQ_EVENT_CLOSED = 128,
336
- ZMQ_EVENT_CLOSE_FAILED = 256,
337
- ZMQ_EVENT_DISCONNECTED = 512,
338
- ZMQ_EVENT_MONITOR_STOPPED = 1024
339
- };
330
+ #define ZMQ_EVENT_CLOSED 128
331
+ #define ZMQ_EVENT_CLOSE_FAILED 256
332
+ #define ZMQ_EVENT_DISCONNECTED 512
333
+ #define ZMQ_EVENT_MONITOR_STOPPED 1024
340
334
 
341
335
  #define ZMQ_EVENT_ALL ( ZMQ_EVENT_CONNECTED | ZMQ_EVENT_CONNECT_DELAYED | \
342
336
  ZMQ_EVENT_CONNECT_RETRIED | ZMQ_EVENT_LISTENING | \
@@ -379,15 +373,9 @@ ZMQ_EXPORT int zmq_recviov (void *s, struct iovec *iov, size_t *count, int flags
379
373
  /* I/O multiplexing. */
380
374
  /******************************************************************************/
381
375
 
382
- enum zmq_poll_types_t {
383
- ZMQ_POLLIN = 1,
384
- ZMQ_POLLOUT = 2,
385
- ZMQ_POLLERR = 4
386
- };
387
-
388
- enum zmq_poll_defaults_t {
389
- ZMQ_POLLITEMS_DFLT = 16
390
- };
376
+ #define ZMQ_POLLIN 1
377
+ #define ZMQ_POLLOUT 2
378
+ #define ZMQ_POLLERR 4
391
379
 
392
380
  typedef struct
393
381
  {
@@ -401,6 +389,8 @@ typedef struct
401
389
  short revents;
402
390
  } zmq_pollitem_t;
403
391
 
392
+ #define ZMQ_POLLITEMS_DFLT 16
393
+
404
394
  ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout);
405
395
 
406
396
  /* Built-in message proxy (3-way) */
@@ -413,28 +403,13 @@ ZMQ_EXPORT char *zmq_z85_encode (char *dest, uint8_t *data, size_t size);
413
403
  /* Encode a binary key from printable text per ZMQ RFC 32 */
414
404
  ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, char *string);
415
405
 
406
+ /* Deprecated aliases */
407
+ #define ZMQ_STREAMER 1
408
+ #define ZMQ_FORWARDER 2
409
+ #define ZMQ_QUEUE 3
416
410
  /* Deprecated method */
417
411
  ZMQ_EXPORT int zmq_device (int type, void *frontend, void *backend);
418
412
 
419
- /* Deprecated options and aliases */
420
- enum zmq_deprecated_t {
421
- /* Misc */
422
- ZMQ_IPV4ONLY = 31,
423
- ZMQ_DELAY_ATTACH_ON_CONNECT = ZMQ_IMMEDIATE,
424
- ZMQ_NOBLOCK = ZMQ_DONTWAIT,
425
- ZMQ_FAIL_UNROUTABLE = ZMQ_ROUTER_MANDATORY,
426
- ZMQ_ROUTER_BEHAVIOR = ZMQ_ROUTER_MANDATORY,
427
-
428
- /* Socket aliases */
429
- ZMQ_XREQ=ZMQ_DEALER,
430
- ZMQ_XREP=ZMQ_ROUTER,
431
-
432
- /* I/O aliasses */
433
- ZMQ_STREAMER = 1,
434
- ZMQ_FORWARDER = 2,
435
- ZMQ_QUEUE = 3
436
- };
437
-
438
413
  #undef ZMQ_EXPORT
439
414
 
440
415
  #ifdef __cplusplus
@@ -132,8 +132,8 @@ namespace zmq
132
132
  sockets_t sockets;
133
133
 
134
134
  // List of unused thread slots.
135
- typedef std::vector <uint32_t> emtpy_slots_t;
136
- emtpy_slots_t empty_slots;
135
+ typedef std::vector <uint32_t> empty_slots_t;
136
+ empty_slots_t empty_slots;
137
137
 
138
138
  // If true, zmq_init has been called but no socket has been created
139
139
  // yet. Launching of I/O threads is delayed.