Update mechanism API so we can check for ERROR status

This commit is contained in:
Martin Hurton
2014-05-06 17:07:50 +02:00
parent 8672f3023a
commit 0be8144176
10 changed files with 43 additions and 28 deletions

View File

@@ -670,17 +670,21 @@ int zmq::stream_engine_t::next_handshake_command (msg_t *msg_)
{
zmq_assert (mechanism != NULL);
const int rc = mechanism->next_handshake_command (msg_);
if (rc == 0) {
msg_->set_flags (msg_t::command);
if (mechanism->is_handshake_complete ())
mechanism_ready ();
if (mechanism->status () == mechanism_t::ready) {
mechanism_ready ();
return pull_and_encode (msg_);
}
else
if (mechanism->status () == mechanism_t::error) {
errno = EPROTO;
return -1;
}
else {
const int rc = mechanism->next_handshake_command (msg_);
if (rc == 0)
msg_->set_flags (msg_t::command);
return rc;
}
// TODO:
// if (errno == EPROTO || errno == EACCES)
// return ERROR command to client
return rc;
}
int zmq::stream_engine_t::process_handshake_command (msg_t *msg_)
@@ -688,14 +692,16 @@ int zmq::stream_engine_t::process_handshake_command (msg_t *msg_)
zmq_assert (mechanism != NULL);
const int rc = mechanism->process_handshake_command (msg_);
if (rc == 0) {
if (mechanism->is_handshake_complete ())
if (mechanism->status () == mechanism_t::ready)
mechanism_ready ();
else
if (mechanism->status () == mechanism_t::error) {
errno = EPROTO;
return -1;
}
if (output_stopped)
restart_output ();
}
// TODO:
// if (errno == EPROTO || errno == EACCES)
// return ERROR command to client
return rc;
}