Assert in PUB from two SUBs connecting with the same identity

Description

If I connect to a PUB socket with two SUB sockets with the same identity, the PUB side throws an assert when it tries to send:

Assertion failed: new_sndbuf > old_sndbuf (mailbox.cpp:182)
Aborted

bug.c

#include <zmq.h>
#include <assert.h>

int main () {
void *context = zmq_init (1);

// We send updates via this socket
void *sub1 = zmq_socket (context, ZMQ_PUB);
zmq_setsockopt(sub1, ZMQ_IDENTITY, "test", sizeof("test"));
zmq_connect (sub1, "tcp://*:5565");
void *sub2 = zmq_socket (context, ZMQ_PUB);
zmq_setsockopt(sub2, ZMQ_IDENTITY, "test", sizeof("test"));
zmq_connect (sub2, "tcp://*:5565");

zmq_msg_t message;
zmq_msg_init (&message);
zmq_recv(sub1, &message, 0);

zmq_close (sub1);
zmq_close (sub2);
zmq_term (context);
return 0;
}

bugserver.c (where the assert happens)

#include <zmq.h>
#include <string.h>

int main () {
void *context = zmq_init (1);

// We send updates via this socket
void *publisher = zmq_socket (context, ZMQ_PUB);
zmq_bind (publisher, "tcp://*:5565");

zmq_msg_t message;
zmq_msg_init_size (&message, sizeof("test")-1);
memcpy (zmq_msg_data (&message), "test", sizeof("test")-1);
zmq_send(publisher, &message, 0);

sleep(1);

zmq_close (publisher);
zmq_term (context);
return 0;
}

Environment

None

Assignee

Unassigned

Reporter

Ian Barber

Labels

None

Priority

Configure