0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-21 23:19:31 +08:00

Never exchange identities for sockets in raw mode

Zeromq shall never send/receive socket identifiers for sockets in raw
mode. The existing implementation breaks this requirement after
reconnection.
This commit is contained in:
Martin Hurton 2012-11-08 18:17:11 +01:00
parent aec47b3642
commit c1e960b31d

View File

@ -120,11 +120,6 @@ zmq::session_base_t::session_base_t (class io_thread_t *io_thread_,
identity_received (false), identity_received (false),
addr (addr_) addr (addr_)
{ {
// Identities are not exchanged for raw sockets
if (options.raw_sock) {
identity_sent = true;
identity_received = true;
}
} }
zmq::session_base_t::~session_base_t () zmq::session_base_t::~session_base_t ()
@ -156,8 +151,9 @@ void zmq::session_base_t::attach_pipe (pipe_t *pipe_)
int zmq::session_base_t::pull_msg (msg_t *msg_) int zmq::session_base_t::pull_msg (msg_t *msg_)
{ {
// First message to send is identity // Unless the socket is in raw mode, the first
if (unlikely (!identity_sent)) { // message we send is its identity.
if (unlikely (!identity_sent && !options.raw_sock)) {
int rc = msg_->init_size (options.identity_size); int rc = msg_->init_size (options.identity_size);
errno_assert (rc == 0); errno_assert (rc == 0);
memcpy (msg_->data (), options.identity, options.identity_size); memcpy (msg_->data (), options.identity, options.identity_size);
@ -177,8 +173,9 @@ int zmq::session_base_t::pull_msg (msg_t *msg_)
int zmq::session_base_t::push_msg (msg_t *msg_) int zmq::session_base_t::push_msg (msg_t *msg_)
{ {
// First message to receive is identity // Unless the socket is in raw mode, the first
if (unlikely (!identity_received)) { // message we receive is its identity.
if (unlikely (!identity_received && !options.raw_sock)) {
msg_->set_flags (msg_t::identity); msg_->set_flags (msg_t::identity);
identity_received = true; identity_received = true;
if (!options.recv_identity) { if (!options.recv_identity) {