mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-27 19:10:22 +01:00
Problem: commit afb24b53 broke ZMQ_STREAM contract
Symptom is that ZMQ_STREAM sockets in 4.1.0 and 4.1.1 generate zero sized messages on each new connection, unlike 4.0.x which did not do this. Person who made this commit also changed test cases so that contract breakage did not show. Same person was later banned for persistently poor form in CZMQ contributions. Solution: enable connect notifications on ZMQ_STREAM sockets using a new ZMQ_STREAM_NOTIFY setting. By default, socket does not deliver notifications, and behaves as in 4.0.x. Fixes #1316
This commit is contained in:
@@ -33,7 +33,7 @@ zmq::stream_t::stream_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
|
||||
next_rid (generate_random ())
|
||||
{
|
||||
options.type = ZMQ_STREAM;
|
||||
options.raw_sock = true;
|
||||
options.raw_socket = true;
|
||||
|
||||
prefetched_id.init ();
|
||||
prefetched_msg.init ();
|
||||
@@ -167,6 +167,8 @@ int zmq::stream_t::xsend (msg_t *msg_)
|
||||
int zmq::stream_t::xsetsockopt (int option_, const void *optval_,
|
||||
size_t optvallen_)
|
||||
{
|
||||
bool is_int = (optvallen_ == sizeof (int));
|
||||
int value = is_int? *((int *) optval_): 0;
|
||||
switch (option_) {
|
||||
case ZMQ_CONNECT_RID:
|
||||
if (optval_ && optvallen_) {
|
||||
@@ -174,6 +176,14 @@ int zmq::stream_t::xsetsockopt (int option_, const void *optval_,
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case ZMQ_STREAM_NOTIFY:
|
||||
if (is_int && (value == 0 || value == 1)) {
|
||||
options.raw_notify = value;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user