Skip to content

Commit

Permalink
Problem: Message metadata properties still refer to "identity"
Browse files Browse the repository at this point in the history
Solution: Renamed, but support querying the property by its old name
  • Loading branch information
sigiesec committed Sep 19, 2017
1 parent 27c7e52 commit fab5763
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 1 addition & 2 deletions include/zmq.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,7 @@ ZMQ_EXPORT int zmq_msg_set_group(zmq_msg_t *msg, const char *group);
ZMQ_EXPORT const char *zmq_msg_group(zmq_msg_t *msg);

/* DRAFT Msg property names. */
// TODO the name of the define AND its value are now inconsistent with the new term "routing id"
#define ZMQ_MSG_PROPERTY_IDENTITY "Identity"
#define ZMQ_MSG_PROPERTY_ROUTING_ID "Routing-Id"
#define ZMQ_MSG_PROPERTY_SOCKET_TYPE "Socket-Type"
#define ZMQ_MSG_PROPERTY_USER_ID "User-Id"
#define ZMQ_MSG_PROPERTY_PEER_ADDRESS "Peer-Address"
Expand Down
8 changes: 4 additions & 4 deletions src/mechanism.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ size_t zmq::mechanism_t::add_basic_properties (unsigned char *buf,
ZMQ_MSG_PROPERTY_SOCKET_TYPE, socket_type,
strlen (socket_type));

// Add identity property
// Add routing id property
if (options.type == ZMQ_REQ || options.type == ZMQ_DEALER
|| options.type == ZMQ_ROUTER)
ptr += add_property (ptr, buf_capacity - (ptr - buf),
ZMQ_MSG_PROPERTY_IDENTITY, options.routing_id,
ZMQ_MSG_PROPERTY_ROUTING_ID, options.routing_id,
options.routing_id_size);

return ptr - buf;
Expand All @@ -148,7 +148,7 @@ size_t zmq::mechanism_t::basic_properties_len() const
return property_len (ZMQ_MSG_PROPERTY_SOCKET_TYPE, strlen (socket_type))
+ ((options.type == ZMQ_REQ || options.type == ZMQ_DEALER
|| options.type == ZMQ_ROUTER)
? property_len (ZMQ_MSG_PROPERTY_IDENTITY,
? property_len (ZMQ_MSG_PROPERTY_ROUTING_ID,
options.routing_id_size)
: 0);
}
Expand Down Expand Up @@ -199,7 +199,7 @@ int zmq::mechanism_t::parse_metadata (const unsigned char *ptr_,
ptr_ += value_length;
bytes_left -= value_length;

if (name == ZMQ_MSG_PROPERTY_IDENTITY && options.recv_routing_id)
if (name == ZMQ_MSG_PROPERTY_ROUTING_ID && options.recv_routing_id)
set_peer_routing_id (value, value_length);
else
if (name == ZMQ_MSG_PROPERTY_SOCKET_TYPE) {
Expand Down
8 changes: 7 additions & 1 deletion src/metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ zmq::metadata_t::metadata_t (const dict_t &dict) :
const char *zmq::metadata_t::get (const std::string &property) const
{
dict_t::const_iterator it = dict.find (property);
if (it == dict.end ())
if (it == dict.end())
{
/** \todo remove this when support for the deprecated name "Identity" is dropped */
if (property == "Identity")
return get (ZMQ_MSG_PROPERTY_ROUTING_ID);

return NULL;
}
else
return it->second.c_str ();
}
Expand Down

0 comments on commit fab5763

Please sign in to comment.