mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 15:41:05 +08:00
Problem: zmq_msg_gets did not set errno on unknown properties
Solution: set errno to EINVAL when a property does not exist. Also fixed test_metadata.cpp to test this case.
This commit is contained in:
parent
6e91330a0c
commit
dd05a64462
@ -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