Commit 87f2dff3 authored by Pieter Hintjens's avatar Pieter Hintjens

Problem: zmq_msg_get_routing_id () is not consistent with API

We do not use 'get' for getters.

Solution: rename to zmq_msg_routing_id () for public API.
parent 7be6ad05
...@@ -227,8 +227,8 @@ ZMQ_EXPORT int zmq_msg_more (zmq_msg_t *msg); ...@@ -227,8 +227,8 @@ ZMQ_EXPORT int zmq_msg_more (zmq_msg_t *msg);
ZMQ_EXPORT int zmq_msg_get (zmq_msg_t *msg, int property); ZMQ_EXPORT int zmq_msg_get (zmq_msg_t *msg, int property);
ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int property, int optval); ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int property, int optval);
ZMQ_EXPORT const char *zmq_msg_gets (zmq_msg_t *msg, const char *property); ZMQ_EXPORT const char *zmq_msg_gets (zmq_msg_t *msg, const char *property);
ZMQ_EXPORT int zmq_msg_set_routing_id(zmq_msg_t *msg, uint32_t routing_id); ZMQ_EXPORT int zmq_msg_set_routing_id (zmq_msg_t *msg, uint32_t routing_id);
ZMQ_EXPORT uint32_t zmq_msg_get_routing_id(zmq_msg_t *msg); ZMQ_EXPORT uint32_t zmq_msg_routing_id (zmq_msg_t *msg);
/******************************************************************************/ /******************************************************************************/
......
...@@ -497,18 +497,18 @@ bool zmq::msg_t::rm_refs (int refs_) ...@@ -497,18 +497,18 @@ bool zmq::msg_t::rm_refs (int refs_)
return true; return true;
} }
uint32_t zmq::msg_t::get_routing_id() uint32_t zmq::msg_t::get_routing_id ()
{ {
return u.base.routing_id; return u.base.routing_id;
} }
int zmq::msg_t::set_routing_id(uint32_t routing_id_) int zmq::msg_t::set_routing_id (uint32_t routing_id_)
{ {
u.base.routing_id = routing_id_; u.base.routing_id = routing_id_;
return 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)
{ {
......
...@@ -97,8 +97,8 @@ namespace zmq ...@@ -97,8 +97,8 @@ namespace zmq
bool is_vsm () const; bool is_vsm () const;
bool is_cmsg () const; bool is_cmsg () const;
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_);
// 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.
......
...@@ -85,8 +85,8 @@ namespace zmq ...@@ -85,8 +85,8 @@ namespace zmq
void set_event_sink (i_pipe_events *sink_); void set_event_sink (i_pipe_events *sink_);
// Pipe endpoint can store an routing ID to be used by its clients. // Pipe endpoint can store an routing ID to be used by its clients.
void set_routing_id(uint32_t routing_id_); void set_routing_id (uint32_t routing_id_);
uint32_t get_routing_id(); uint32_t get_routing_id ();
// Pipe endpoint can store an opaque ID to be used by its clients. // Pipe endpoint can store an opaque ID to be used by its clients.
void set_identity (const blob_t &identity_); void set_identity (const blob_t &identity_);
......
...@@ -93,7 +93,7 @@ int zmq::server_t::xsend (msg_t *msg_) ...@@ -93,7 +93,7 @@ int zmq::server_t::xsend (msg_t *msg_)
zmq_assert(!(msg_->flags () & msg_t::more)); zmq_assert(!(msg_->flags () & msg_t::more));
// Find the pipe associated with the routing stored in the message. // Find the pipe associated with the routing stored in the message.
uint32_t routing_id = msg_->get_routing_id(); uint32_t routing_id = msg_->get_routing_id ();
outpipes_t::iterator it = outpipes.find (routing_id); outpipes_t::iterator it = outpipes.find (routing_id);
if (it != outpipes.end ()) { if (it != outpipes.end ()) {
...@@ -148,8 +148,8 @@ int zmq::server_t::xrecv (msg_t *msg_) ...@@ -148,8 +148,8 @@ int zmq::server_t::xrecv (msg_t *msg_)
zmq_assert (pipe != NULL); zmq_assert (pipe != NULL);
uint32_t routing_id = pipe->get_routing_id(); uint32_t routing_id = pipe->get_routing_id ();
msg_->set_routing_id(routing_id); msg_->set_routing_id (routing_id);
return 0; return 0;
} }
......
...@@ -686,19 +686,19 @@ int zmq_msg_set (zmq_msg_t *, int, int) ...@@ -686,19 +686,19 @@ int zmq_msg_set (zmq_msg_t *, int, int)
int zmq_msg_set_routing_id (zmq_msg_t *msg_, uint32_t routing_id_) int zmq_msg_set_routing_id (zmq_msg_t *msg_, uint32_t routing_id_)
{ {
return ((zmq::msg_t*) msg_)->set_routing_id(routing_id_); return ((zmq::msg_t *) msg_)->set_routing_id (routing_id_);
} }
uint32_t zmq_msg_get_routing_id(zmq_msg_t *msg_) uint32_t zmq_msg_routing_id (zmq_msg_t *msg_)
{ {
return ((zmq::msg_t*) msg_)->get_routing_id(); return ((zmq::msg_t *) msg_)->get_routing_id ();
} }
// Get message metadata string // Get message metadata string
const char *zmq_msg_gets (zmq_msg_t *msg_, const char *property_) const char *zmq_msg_gets (zmq_msg_t *msg_, const char *property_)
{ {
zmq::metadata_t *metadata = ((zmq::msg_t*) msg_)->metadata (); zmq::metadata_t *metadata = ((zmq::msg_t *) msg_)->metadata ();
const char *value = NULL; const char *value = NULL;
if (metadata) if (metadata)
value = metadata->get (std::string (property_)); value = metadata->get (std::string (property_));
......
...@@ -38,31 +38,29 @@ int main (void) ...@@ -38,31 +38,29 @@ 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; int rc = zmq_bind (server, "tcp://127.0.0.1:5560");
rc = zmq_bind (server, "tcp://127.0.0.1:5560");
assert (rc == 0); assert (rc == 0);
rc = zmq_connect (client, "tcp://127.0.0.1:5560"); rc = zmq_connect (client, "tcp://127.0.0.1:5560");
assert (rc == 0); assert (rc == 0);
zmq_msg_t msg; zmq_msg_t msg;
rc = zmq_msg_init_size(&msg,1); rc = zmq_msg_init_size (&msg, 1);
assert (rc == 0); assert (rc == 0);
char * data = (char *)zmq_msg_data(&msg); char *data = (char *) zmq_msg_data (&msg);
data[0] = 1; data [0] = 1;
rc = zmq_msg_send(&msg, client, 0); rc = zmq_msg_send(&msg, client, 0);
assert (rc == 1); assert (rc == 1);
rc = zmq_msg_init(&msg); rc = zmq_msg_init (&msg);
assert (rc == 0); assert (rc == 0);
rc = zmq_msg_recv(&msg, server, 0); rc = zmq_msg_recv (&msg, server, 0);
assert (rc == 1); assert (rc == 1);
uint32_t routing_id = zmq_msg_get_routing_id(&msg); uint32_t routing_id = zmq_msg_routing_id (&msg);
assert(routing_id != 0); assert (routing_id != 0);
rc = zmq_msg_close(&msg); rc = zmq_msg_close(&msg);
assert (rc == 0); assert (rc == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment