-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
Starting with libzmq 4.3.0, this code crashes:
int main()
{
zmq::context_t ctx;
zmq::socket_t publisher(ctx, ZMQ_XPUB);
publisher.bind("inproc://test");
zmq::socket_t receiver(ctx, ZMQ_XSUB);
receiver.connect("inproc://test");
zmq::message_t subscribe(1);
*static_cast<unsigned char *>(subscribe.data()) = 2;
receiver.send(subscribe);
zmq::message_t receive;
publisher.recv(&receive);
return 0;
}
Note that instead of activating subscription (1) or cancelling it (0), I simply send user data (2). The problem is that this code for handling user messages comming upstream never executes:
Lines 114 to 123 in c737e57
| } else { | |
| // Process user message coming upstream from xsub socket | |
| _pending_data.push_back (blob_t (msg_data, sub.size ())); | |
| if (metadata) | |
| metadata->add_ref (); | |
| _pending_metadata.push_back (metadata); | |
| _pending_flags.push_back (sub.flags ()); | |
| sub.close (); | |
| continue; | |
| } |
Instead, the above else is activated, but it just skip the data processing if first byte is not 0 or 1. Also, this else kind of duplicates above if.
As a result, my code which needs to send upstream data from XSUB to XPUB does not work with libzmq 4.3.0 or higher. Any way how to resolve this?