Commit 40d7ca6a authored by Pieter Hintjens's avatar Pieter Hintjens

Whitespace cleanups

parent 1fe82ae0
......@@ -99,14 +99,11 @@ int zmq::ctx_t::terminate ()
if (!starting) {
#ifdef HAVE_FORK
if (pid != getpid())
{
if (pid != getpid ()) {
// we are a forked child process. Close all file descriptors
// inherited from the parent.
for (sockets_t::size_type i = 0; i != sockets.size (); i++)
{
sockets[i]->get_mailbox()->forked();
}
term_mailbox.forked();
}
......@@ -118,7 +115,6 @@ int zmq::ctx_t::terminate ()
// First attempt to terminate the context.
if (!restarted) {
// First send stop command to sockets so that any blocking calls
// can be interrupted. If there are no sockets we can ask reaper
// thread to stop.
......@@ -351,7 +347,6 @@ int zmq::ctx_t::register_endpoint (const char *addr_, endpoint_t &endpoint_)
errno = EADDRINUSE;
return -1;
}
return 0;
}
......@@ -369,7 +364,6 @@ void zmq::ctx_t::unregister_endpoints (socket_base_t *socket_)
}
++it;
}
endpoints_sync.unlock ();
}
......@@ -401,17 +395,14 @@ void zmq::ctx_t::pend_connection (const char *addr_, pending_connection_t &pendi
endpoints_sync.lock ();
endpoints_t::iterator it = endpoints.find (addr_);
if (it == endpoints.end ())
{
if (it == endpoints.end ()) {
// Still no bind.
pending_connection_.endpoint.socket->inc_seqnum ();
pending_connections.insert (pending_connections_t::value_type (std::string (addr_), pending_connection_));
}
else
{
// Bind has happened in the mean time, connect directly
connect_inproc_sockets(it->second.socket, it->second.options, pending_connection_, connect_side);
}
endpoints_sync.unlock ();
}
......@@ -423,22 +414,19 @@ void zmq::ctx_t::connect_pending (const char *addr_, zmq::socket_base_t *bind_so
std::pair<pending_connections_t::iterator, pending_connections_t::iterator> pending = pending_connections.equal_range(addr_);
for (pending_connections_t::iterator p = pending.first; p != pending.second; ++p)
{
connect_inproc_sockets(bind_socket_, endpoints[addr_].options, p->second, bind_side);
}
pending_connections.erase(pending.first, pending.second);
endpoints_sync.unlock ();
}
void zmq::ctx_t::connect_inproc_sockets(zmq::socket_base_t *bind_socket_, options_t& bind_options, pending_connection_t &pending_connection_, side side_)
void zmq::ctx_t::connect_inproc_sockets (zmq::socket_base_t *bind_socket_,
options_t& bind_options, pending_connection_t &pending_connection_, side side_)
{
bind_socket_->inc_seqnum();
pending_connection_.bind_pipe->set_tid(bind_socket_->get_tid());
if (side_ == bind_side)
{
if (side_ == bind_side) {
command_t cmd;
cmd.type = command_t::bind;
cmd.args.bind.pipe = pending_connection_.bind_pipe;
......@@ -446,13 +434,12 @@ void zmq::ctx_t::connect_inproc_sockets(zmq::socket_base_t *bind_socket_, option
bind_socket_->send_inproc_connected(pending_connection_.endpoint.socket);
}
else
{
pending_connection_.connect_pipe->send_bind(bind_socket_, pending_connection_.bind_pipe, false);
}
int sndhwm = 0;
if (pending_connection_.endpoint.options.sndhwm != 0 && bind_options.rcvhwm != 0)
sndhwm = pending_connection_.endpoint.options.sndhwm + bind_options.rcvhwm;
int rcvhwm = 0;
if (pending_connection_.endpoint.options.rcvhwm != 0 && bind_options.sndhwm != 0)
rcvhwm = pending_connection_.endpoint.options.rcvhwm + bind_options.sndhwm;
......@@ -473,7 +460,8 @@ void zmq::ctx_t::connect_inproc_sockets(zmq::socket_base_t *bind_socket_, option
msg_t id;
int rc = id.init_size (pending_connection_.endpoint.options.identity_size);
errno_assert (rc == 0);
memcpy (id.data (), pending_connection_.endpoint.options.identity, pending_connection_.endpoint.options.identity_size);
memcpy (id.data (), pending_connection_.endpoint.options.identity,
pending_connection_.endpoint.options.identity_size);
id.set_flags (msg_t::identity);
bool written = pending_connection_.connect_pipe->write (&id);
zmq_assert (written);
......
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