mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-19 08:46:44 +01:00
Merge pull request #1716 from somdoron/master
Problem: client over inproc receives the msg with routing id set
This commit is contained in:
commit
cc29578088
@ -512,6 +512,12 @@ int zmq::msg_t::set_routing_id (uint32_t routing_id_)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int zmq::msg_t::reset_routing_id ()
|
||||||
|
{
|
||||||
|
u.base.routing_id = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
zmq::atomic_counter_t *zmq::msg_t::refcnt()
|
zmq::atomic_counter_t *zmq::msg_t::refcnt()
|
||||||
{
|
{
|
||||||
switch(u.base.type)
|
switch(u.base.type)
|
||||||
|
@ -99,6 +99,7 @@ namespace zmq
|
|||||||
bool is_zcmsg() const;
|
bool is_zcmsg() const;
|
||||||
uint32_t get_routing_id ();
|
uint32_t get_routing_id ();
|
||||||
int set_routing_id (uint32_t routing_id_);
|
int set_routing_id (uint32_t routing_id_);
|
||||||
|
int reset_routing_id ();
|
||||||
|
|
||||||
// After calling this function you can copy the message in POD-style
|
// After calling this function you can copy the message in POD-style
|
||||||
// refs_ times. No need to call copy.
|
// refs_ times. No need to call copy.
|
||||||
|
@ -113,6 +113,11 @@ int zmq::server_t::xsend (msg_t *msg_)
|
|||||||
errno = EHOSTUNREACH;
|
errno = EHOSTUNREACH;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Message might be delivired over inproc, so we reset routing id
|
||||||
|
int rc = msg_->reset_routing_id ();
|
||||||
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
bool ok = it->second.pipe->write (msg_);
|
bool ok = it->second.pipe->write (msg_);
|
||||||
if (unlikely (!ok)) {
|
if (unlikely (!ok)) {
|
||||||
// Message failed to send - we must close it ourselves.
|
// Message failed to send - we must close it ourselves.
|
||||||
@ -123,7 +128,7 @@ int zmq::server_t::xsend (msg_t *msg_)
|
|||||||
it->second.pipe->flush ();
|
it->second.pipe->flush ();
|
||||||
|
|
||||||
// Detach the message from the data buffer.
|
// Detach the message from the data buffer.
|
||||||
int rc = msg_->init ();
|
rc = msg_->init ();
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -38,10 +38,10 @@ int main (void)
|
|||||||
void *server = zmq_socket (ctx, ZMQ_SERVER);
|
void *server = zmq_socket (ctx, ZMQ_SERVER);
|
||||||
void *client = zmq_socket (ctx, ZMQ_CLIENT);
|
void *client = zmq_socket (ctx, ZMQ_CLIENT);
|
||||||
|
|
||||||
int rc = zmq_bind (server, "tcp://127.0.0.1:5560");
|
int rc = zmq_bind (server, "inproc://test-client-server");
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
rc = zmq_connect (client, "tcp://127.0.0.1:5560");
|
rc = zmq_connect (client, "inproc://test-client-server");
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
zmq_msg_t msg;
|
zmq_msg_t msg;
|
||||||
@ -87,6 +87,9 @@ int main (void)
|
|||||||
rc = zmq_msg_recv (&msg, client, 0);
|
rc = zmq_msg_recv (&msg, client, 0);
|
||||||
assert (rc == 1);
|
assert (rc == 1);
|
||||||
|
|
||||||
|
routing_id = zmq_msg_routing_id (&msg);
|
||||||
|
assert (routing_id == 0);
|
||||||
|
|
||||||
rc = zmq_msg_close (&msg);
|
rc = zmq_msg_close (&msg);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
@ -101,5 +104,3 @@ int main (void)
|
|||||||
|
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user