mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 19:52:00 +01:00
Problem: tests without ZAP handler are failing
Solution: emit events as expected by tests, and refuse connections when ZAP is required but no handler started Addresses #2711 partially
This commit is contained in:
@@ -48,15 +48,9 @@ zmq::null_mechanism_t::null_mechanism_t (session_base_t *session_,
|
||||
error_command_sent (false),
|
||||
ready_command_received (false),
|
||||
error_command_received (false),
|
||||
zap_connected (false),
|
||||
zap_request_sent (false),
|
||||
zap_reply_received (false)
|
||||
{
|
||||
// NULL mechanism only uses ZAP if there's a domain defined
|
||||
// This prevents ZAP requests on naive sockets
|
||||
if (options.zap_domain.size () > 0
|
||||
&& session->zap_connect () == 0)
|
||||
zap_connected = true;
|
||||
}
|
||||
|
||||
zmq::null_mechanism_t::~null_mechanism_t ()
|
||||
@@ -69,14 +63,23 @@ int zmq::null_mechanism_t::next_handshake_command (msg_t *msg_)
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
if (zap_connected && !zap_reply_received) {
|
||||
|
||||
if (zap_required() && !zap_reply_received) {
|
||||
if (zap_request_sent) {
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
int rc = session->zap_connect();
|
||||
if (rc == -1)
|
||||
{
|
||||
session->get_socket()->event_handshake_failed_no_detail (
|
||||
session->get_endpoint(),
|
||||
EFAULT);
|
||||
return -1;
|
||||
}
|
||||
send_zap_request ();
|
||||
zap_request_sent = true;
|
||||
int rc = receive_and_process_zap_reply ();
|
||||
rc = receive_and_process_zap_reply ();
|
||||
if (rc == -1 || rc == 1)
|
||||
return -1;
|
||||
zap_reply_received = true;
|
||||
@@ -205,6 +208,13 @@ zmq::mechanism_t::status_t zmq::null_mechanism_t::status () const
|
||||
return handshaking;
|
||||
}
|
||||
|
||||
bool zmq::null_mechanism_t::zap_required() const
|
||||
{
|
||||
// NULL mechanism only uses ZAP if there's a domain defined
|
||||
// This prevents ZAP requests on naive sockets
|
||||
return options.zap_domain.size() > 0;
|
||||
}
|
||||
|
||||
void zmq::null_mechanism_t::send_zap_request ()
|
||||
{
|
||||
zap_client_t::send_zap_request ("NULL", 4, NULL, NULL, 0);
|
||||
|
||||
Reference in New Issue
Block a user