mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-31 14:39:55 +01:00
Merge pull request #1111 from hintjens/master
Problem: zmq_msg_gets did not set errno on unknown properties
This commit is contained in:
commit
7e8dd46631
@ -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_)
|
||||
{
|
||||
zmq::metadata_t *metadata = ((zmq::msg_t*) msg_)->metadata ();
|
||||
const char *value = NULL;
|
||||
if (metadata)
|
||||
return metadata->get (std::string (property_));
|
||||
else
|
||||
value = metadata->get (std::string (property_));
|
||||
if (value)
|
||||
return value;
|
||||
else {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Polling.
|
||||
|
@ -100,6 +100,8 @@ int main (void)
|
||||
assert (streq (zmq_msg_gets (&msg, "Hello"), "World"));
|
||||
assert (streq (zmq_msg_gets (&msg, "Socket-Type"), "DEALER"));
|
||||
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);
|
||||
|
||||
close_zero_linger (client);
|
||||
|
Loading…
x
Reference in New Issue
Block a user