Problem: Message metadata properties still refer to "identity"

Solution: Renamed, but support querying the property by its old name
This commit is contained in:
sigiesec 2017-09-07 09:55:56 +02:00
parent 27c7e52a5a
commit fab57634b4
3 changed files with 12 additions and 7 deletions

View File

@ -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); ZMQ_EXPORT const char *zmq_msg_group(zmq_msg_t *msg);
/* DRAFT Msg property names. */ /* 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_ROUTING_ID "Routing-Id"
#define ZMQ_MSG_PROPERTY_IDENTITY "Identity"
#define ZMQ_MSG_PROPERTY_SOCKET_TYPE "Socket-Type" #define ZMQ_MSG_PROPERTY_SOCKET_TYPE "Socket-Type"
#define ZMQ_MSG_PROPERTY_USER_ID "User-Id" #define ZMQ_MSG_PROPERTY_USER_ID "User-Id"
#define ZMQ_MSG_PROPERTY_PEER_ADDRESS "Peer-Address" #define ZMQ_MSG_PROPERTY_PEER_ADDRESS "Peer-Address"

View File

@ -132,11 +132,11 @@ size_t zmq::mechanism_t::add_basic_properties (unsigned char *buf,
ZMQ_MSG_PROPERTY_SOCKET_TYPE, socket_type, ZMQ_MSG_PROPERTY_SOCKET_TYPE, socket_type,
strlen (socket_type)); strlen (socket_type));
// Add identity property // Add routing id property
if (options.type == ZMQ_REQ || options.type == ZMQ_DEALER if (options.type == ZMQ_REQ || options.type == ZMQ_DEALER
|| options.type == ZMQ_ROUTER) || options.type == ZMQ_ROUTER)
ptr += add_property (ptr, buf_capacity - (ptr - buf), 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); options.routing_id_size);
return ptr - buf; return ptr - buf;
@ -148,7 +148,7 @@ size_t zmq::mechanism_t::basic_properties_len() const
return property_len (ZMQ_MSG_PROPERTY_SOCKET_TYPE, strlen (socket_type)) return property_len (ZMQ_MSG_PROPERTY_SOCKET_TYPE, strlen (socket_type))
+ ((options.type == ZMQ_REQ || options.type == ZMQ_DEALER + ((options.type == ZMQ_REQ || options.type == ZMQ_DEALER
|| options.type == ZMQ_ROUTER) || options.type == ZMQ_ROUTER)
? property_len (ZMQ_MSG_PROPERTY_IDENTITY, ? property_len (ZMQ_MSG_PROPERTY_ROUTING_ID,
options.routing_id_size) options.routing_id_size)
: 0); : 0);
} }
@ -199,7 +199,7 @@ int zmq::mechanism_t::parse_metadata (const unsigned char *ptr_,
ptr_ += value_length; ptr_ += value_length;
bytes_left -= 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); set_peer_routing_id (value, value_length);
else else
if (name == ZMQ_MSG_PROPERTY_SOCKET_TYPE) { if (name == ZMQ_MSG_PROPERTY_SOCKET_TYPE) {

View File

@ -40,7 +40,13 @@ const char *zmq::metadata_t::get (const std::string &property) const
{ {
dict_t::const_iterator it = dict.find (property); 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; return NULL;
}
else else
return it->second.c_str (); return it->second.c_str ();
} }