Commit 7e8dd466 authored by Richard Newton's avatar Richard Newton

Merge pull request #1111 from hintjens/master

Problem: zmq_msg_gets did not set errno on unknown properties
parents 3b505f1f dd05a644
...@@ -648,10 +648,15 @@ int zmq_msg_set (zmq_msg_t *, int, int) ...@@ -648,10 +648,15 @@ int zmq_msg_set (zmq_msg_t *, int, int)
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;
if (metadata) if (metadata)
return metadata->get (std::string (property_)); value = metadata->get (std::string (property_));
else if (value)
return value;
else {
errno = EINVAL;
return NULL; return NULL;
}
} }
// Polling. // Polling.
......
...@@ -100,6 +100,8 @@ int main (void) ...@@ -100,6 +100,8 @@ int main (void)
assert (streq (zmq_msg_gets (&msg, "Hello"), "World")); assert (streq (zmq_msg_gets (&msg, "Hello"), "World"));
assert (streq (zmq_msg_gets (&msg, "Socket-Type"), "DEALER")); assert (streq (zmq_msg_gets (&msg, "Socket-Type"), "DEALER"));
assert (streq (zmq_msg_gets (&msg, "User-Id"), "anonymous")); assert (streq (zmq_msg_gets (&msg, "User-Id"), "anonymous"));
assert (zmq_msg_gets (&msg, "No Such") == NULL);
assert (zmq_errno () == EINVAL);
zmq_msg_close (&msg); zmq_msg_close (&msg);
close_zero_linger (client); close_zero_linger (client);
......
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