Commit c0e2bc4e authored by Luca Boccassi's avatar Luca Boccassi

Problem: new DRAFT monitor events returned even without --enable-draft

Solution: wrap the event triggering in the DRAFT ifdef as well as the
defines. This ensures that the event are returned only if the
library was built with DRAFTs enabled.

Also update the test case to expect the new events since it uses
the catch-all mask. Although the sequence of event is different and
this might be considered as an API breakage, using the catch-all
ZMQ_EVENT_ALL mask implies that, well, all events are monitored so
it's normal that new ones will be added.
Users that don't want this kind of behaviour to change can simply
monitor only the event that they care about.
parent 0ebed80d
......@@ -790,8 +790,10 @@ int zmq::stream_engine_t::next_handshake_command (msg_t *msg_)
if (rc == 0)
msg_->set_flags (msg_t::command);
#ifdef ZMQ_BUILD_DRAFT_API
if(mechanism->status() == mechanism_t::error)
socket->event_handshake_failed(endpoint, 0);
#endif
return rc;
}
......@@ -871,7 +873,9 @@ void zmq::stream_engine_t::mechanism_ready ()
if (!properties.empty ())
metadata = new (std::nothrow) metadata_t (properties);
#ifdef ZMQ_BUILD_DRAFT_API
socket->event_handshake_succeed(endpoint, 0);
#endif
}
int zmq::stream_engine_t::pull_msg_from_session (msg_t *msg_)
......@@ -976,8 +980,10 @@ void zmq::stream_engine_t::error (error_reason_t reason)
terminator.close();
}
zmq_assert (session);
#ifdef ZMQ_BUILD_DRAFT_API
if(reason == encryption_error)
socket->event_handshake_failed(endpoint, (int) s);
#endif
socket->event_disconnected (endpoint, (int) s);
session->flush ();
session->engine_error (reason);
......
......@@ -116,6 +116,10 @@ int main (void)
if (event == ZMQ_EVENT_CONNECT_DELAYED)
event = get_monitor_event (client_mon, NULL, NULL);
assert (event == ZMQ_EVENT_CONNECTED);
#ifdef ZMQ_BUILD_DRAFT_API
event = get_monitor_event (client_mon, NULL, NULL);
assert (event == ZMQ_EVENT_HANDSHAKE_SUCCEED);
#endif
event = get_monitor_event (client_mon, NULL, NULL);
assert (event == ZMQ_EVENT_MONITOR_STOPPED);
......@@ -124,6 +128,10 @@ int main (void)
assert (event == ZMQ_EVENT_LISTENING);
event = get_monitor_event (server_mon, NULL, NULL);
assert (event == ZMQ_EVENT_ACCEPTED);
#ifdef ZMQ_BUILD_DRAFT_API
event = get_monitor_event (server_mon, NULL, NULL);
assert (event == ZMQ_EVENT_HANDSHAKE_SUCCEED);
#endif
event = get_monitor_event (server_mon, NULL, NULL);
// Sometimes the server sees the client closing before it gets closed.
if (event != ZMQ_EVENT_DISCONNECTED) {
......
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