mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-31 14:39:55 +01:00
Minor cleanups
This commit is contained in:
parent
c3e40736de
commit
4e47084dd4
@ -340,7 +340,7 @@ void zmq::pipe_t::terminate (bool delay_)
|
|||||||
// There are still pending messages available, but the user calls
|
// There are still pending messages available, but the user calls
|
||||||
// 'terminate'. We can act as if all the pending messages were read.
|
// 'terminate'. We can act as if all the pending messages were read.
|
||||||
else
|
else
|
||||||
if (state == waiting_for_delimiter && delay == 0) {
|
if (state == waiting_for_delimiter && !delay) {
|
||||||
outpipe = NULL;
|
outpipe = NULL;
|
||||||
send_pipe_term_ack (peer);
|
send_pipe_term_ack (peer);
|
||||||
state = term_ack_sent;
|
state = term_ack_sent;
|
||||||
|
@ -110,7 +110,6 @@ int zmq::plain_mechanism_t::process_handshake_message (msg_t *msg_)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool zmq::plain_mechanism_t::is_handshake_complete () const
|
bool zmq::plain_mechanism_t::is_handshake_complete () const
|
||||||
{
|
{
|
||||||
return state == ready;
|
return state == ready;
|
||||||
@ -125,7 +124,7 @@ int zmq::plain_mechanism_t::hello_command (msg_t *msg_) const
|
|||||||
const std::string password = options.plain_password;
|
const std::string password = options.plain_password;
|
||||||
zmq_assert (password.length () < 256);
|
zmq_assert (password.length () < 256);
|
||||||
|
|
||||||
const size_t command_size = 8 + 1 + username.length ()
|
const size_t command_size = 8 + 1 + username.length ()
|
||||||
+ 1 + password.length ();
|
+ 1 + password.length ();
|
||||||
|
|
||||||
const int rc = msg_->init_size (command_size);
|
const int rc = msg_->init_size (command_size);
|
||||||
@ -134,11 +133,11 @@ int zmq::plain_mechanism_t::hello_command (msg_t *msg_) const
|
|||||||
unsigned char *ptr = static_cast <unsigned char *> (msg_->data ());
|
unsigned char *ptr = static_cast <unsigned char *> (msg_->data ());
|
||||||
memcpy (ptr, "HELLO ", 8);
|
memcpy (ptr, "HELLO ", 8);
|
||||||
ptr += 8;
|
ptr += 8;
|
||||||
|
|
||||||
*ptr++ = static_cast <unsigned char> (username.length ());
|
*ptr++ = static_cast <unsigned char> (username.length ());
|
||||||
memcpy (ptr, username.c_str (), username.length ());
|
memcpy (ptr, username.c_str (), username.length ());
|
||||||
ptr += username.length ();
|
ptr += username.length ();
|
||||||
|
|
||||||
*ptr++ = static_cast <unsigned char> (password.length ());
|
*ptr++ = static_cast <unsigned char> (password.length ());
|
||||||
memcpy (ptr, password.c_str (), password.length ());
|
memcpy (ptr, password.c_str (), password.length ());
|
||||||
ptr += password.length ();
|
ptr += password.length ();
|
||||||
@ -163,7 +162,7 @@ int zmq::plain_mechanism_t::process_hello_command (msg_t *msg_)
|
|||||||
errno = EPROTO;
|
errno = EPROTO;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
size_t username_length = static_cast <size_t> (*ptr++);
|
const size_t username_length = static_cast <size_t> (*ptr++);
|
||||||
bytes_left -= 1;
|
bytes_left -= 1;
|
||||||
|
|
||||||
if (bytes_left < username_length) {
|
if (bytes_left < username_length) {
|
||||||
@ -178,7 +177,7 @@ int zmq::plain_mechanism_t::process_hello_command (msg_t *msg_)
|
|||||||
errno = EPROTO;
|
errno = EPROTO;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
size_t password_length = static_cast <size_t> (*ptr++);
|
const size_t password_length = static_cast <size_t> (*ptr++);
|
||||||
bytes_left -= 1;
|
bytes_left -= 1;
|
||||||
|
|
||||||
if (bytes_left < password_length) {
|
if (bytes_left < password_length) {
|
||||||
@ -316,19 +315,19 @@ int zmq::plain_mechanism_t::parse_property_list (const unsigned char *ptr,
|
|||||||
bytes_left -= 1;
|
bytes_left -= 1;
|
||||||
if (bytes_left < name_length)
|
if (bytes_left < name_length)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const std::string name = std::string ((const char *) ptr, name_length);
|
const std::string name = std::string ((const char *) ptr, name_length);
|
||||||
ptr += name_length;
|
ptr += name_length;
|
||||||
bytes_left -= name_length;
|
bytes_left -= name_length;
|
||||||
if (bytes_left < 4)
|
if (bytes_left < 4)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const size_t value_length = static_cast <size_t> (get_uint32 (ptr));
|
const size_t value_length = static_cast <size_t> (get_uint32 (ptr));
|
||||||
ptr += 4;
|
ptr += 4;
|
||||||
bytes_left -= 4;
|
bytes_left -= 4;
|
||||||
if (bytes_left < value_length)
|
if (bytes_left < value_length)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const unsigned char * const value = ptr;
|
const unsigned char * const value = ptr;
|
||||||
ptr += value_length;
|
ptr += value_length;
|
||||||
bytes_left -= value_length;
|
bytes_left -= value_length;
|
||||||
|
@ -217,9 +217,9 @@ void zmq::session_base_t::pipe_terminated (pipe_t *pipe_)
|
|||||||
terminate ();
|
terminate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are waiting for pending messages to be sent, at this point
|
// If we are waiting for pending messages to be sent, at this point
|
||||||
// we are sure that there will be no more messages and we can proceed
|
// we are sure that there will be no more messages and we can proceed
|
||||||
// with termination safely.
|
// with termination safely.
|
||||||
if (pending && !pipe && terminating_pipes.empty ())
|
if (pending && !pipe && terminating_pipes.empty ())
|
||||||
proceed_with_term ();
|
proceed_with_term ();
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ void zmq::session_base_t::process_term (int linger_)
|
|||||||
|
|
||||||
void zmq::session_base_t::proceed_with_term ()
|
void zmq::session_base_t::proceed_with_term ()
|
||||||
{
|
{
|
||||||
// The pending phase have just ended.
|
// The pending phase has just ended.
|
||||||
pending = false;
|
pending = false;
|
||||||
|
|
||||||
// Continue with standard termination.
|
// Continue with standard termination.
|
||||||
|
@ -108,9 +108,9 @@ namespace zmq
|
|||||||
|
|
||||||
// Pipe connecting the session to its socket.
|
// Pipe connecting the session to its socket.
|
||||||
zmq::pipe_t *pipe;
|
zmq::pipe_t *pipe;
|
||||||
|
|
||||||
// This set is added to with pipes we are disconnecting, but haven't yet completed
|
// This set is added to with pipes we are disconnecting, but haven't yet completed
|
||||||
std::set<pipe_t *> terminating_pipes;
|
std::set <pipe_t *> terminating_pipes;
|
||||||
|
|
||||||
// This flag is true if the remainder of the message being processed
|
// This flag is true if the remainder of the message being processed
|
||||||
// is still in the in pipe.
|
// is still in the in pipe.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user