mirror of
https://github.com/zeromq/libzmq.git
synced 2025-11-06 13:21:10 +01:00
Code style improvements
This commit is contained in:
@@ -90,7 +90,7 @@ typedef struct
|
||||
// Utility functions
|
||||
|
||||
int capture (class zmq::socket_base_t *capture_,
|
||||
zmq::msg_t &msg_,
|
||||
zmq::msg_t *msg_,
|
||||
int more_ = 0)
|
||||
{
|
||||
// Copy message to capture socket if any
|
||||
@@ -99,7 +99,7 @@ int capture (class zmq::socket_base_t *capture_,
|
||||
int rc = ctrl.init ();
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
rc = ctrl.copy (msg_);
|
||||
rc = ctrl.copy (*msg_);
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
rc = capture_->send (&ctrl, more_ ? ZMQ_SNDMORE : 0);
|
||||
@@ -114,17 +114,17 @@ int forward (class zmq::socket_base_t *from_,
|
||||
class zmq::socket_base_t *to_,
|
||||
zmq_socket_stats_t *to_stats_,
|
||||
class zmq::socket_base_t *capture_,
|
||||
zmq::msg_t &msg_)
|
||||
zmq::msg_t *msg_)
|
||||
{
|
||||
int more;
|
||||
size_t moresz;
|
||||
size_t complete_msg_size = 0;
|
||||
while (true) {
|
||||
int rc = from_->recv (&msg_, 0);
|
||||
int rc = from_->recv (msg_, 0);
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
|
||||
complete_msg_size += msg_.size ();
|
||||
complete_msg_size += msg_->size ();
|
||||
|
||||
moresz = sizeof more;
|
||||
rc = from_->getsockopt (ZMQ_RCVMORE, &more, &moresz);
|
||||
@@ -136,7 +136,7 @@ int forward (class zmq::socket_base_t *from_,
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
|
||||
rc = to_->send (&msg_, more ? ZMQ_SNDMORE : 0);
|
||||
rc = to_->send (msg_, more ? ZMQ_SNDMORE : 0);
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
|
||||
@@ -163,7 +163,7 @@ static int loop_and_send_multipart_stat (zmq::socket_base_t *control_,
|
||||
|
||||
// VSM of 8 bytes can't fail to init
|
||||
msg.init_size (sizeof (uint64_t));
|
||||
memcpy (msg.data (), (const void *) &stat_, sizeof (uint64_t));
|
||||
memcpy (msg.data (), &stat_, sizeof (uint64_t));
|
||||
|
||||
// if the first message is handed to the pipe successfully then the HWM
|
||||
// is not full, which means failures are due to interrupts (on Windows pipes
|
||||
@@ -366,11 +366,8 @@ int zmq::proxy (class socket_base_t *frontend_,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int i;
|
||||
bool request_processed, reply_processed;
|
||||
|
||||
|
||||
while (state != terminated) {
|
||||
// Blocking wait initially only for 'ZMQ_POLLIN' - 'poller_wait' points to 'poller_in'.
|
||||
// If one of receiving end's queue is full ('ZMQ_POLLOUT' not available),
|
||||
@@ -387,7 +384,7 @@ int zmq::proxy (class socket_base_t *frontend_,
|
||||
CHECK_RC_EXIT_ON_FAILURE ();
|
||||
|
||||
// Process events.
|
||||
for (i = 0; i < rc; i++) {
|
||||
for (int i = 0; i < rc; i++) {
|
||||
if (events[i].socket == frontend_) {
|
||||
frontend_in = (events[i].events & ZMQ_POLLIN) != 0;
|
||||
frontend_out = (events[i].events & ZMQ_POLLOUT) != 0;
|
||||
@@ -413,7 +410,7 @@ int zmq::proxy (class socket_base_t *frontend_,
|
||||
}
|
||||
|
||||
// Copy message to capture socket if any.
|
||||
rc = capture (capture_, msg);
|
||||
rc = capture (capture_, &msg);
|
||||
CHECK_RC_EXIT_ON_FAILURE ();
|
||||
|
||||
if (msg.size () == 5 && memcmp (msg.data (), "PAUSE", 5) == 0) {
|
||||
@@ -452,7 +449,7 @@ int zmq::proxy (class socket_base_t *frontend_,
|
||||
// In case of frontend_==backend_ there's no 'ZMQ_POLLOUT' event.
|
||||
if (frontend_in && (backend_out || frontend_equal_to_backend)) {
|
||||
rc = forward (frontend_, &frontend_stats, backend_,
|
||||
&backend_stats, capture_, msg);
|
||||
&backend_stats, capture_, &msg);
|
||||
CHECK_RC_EXIT_ON_FAILURE ();
|
||||
request_processed = true;
|
||||
frontend_in = backend_out = false;
|
||||
@@ -465,7 +462,7 @@ int zmq::proxy (class socket_base_t *frontend_,
|
||||
// design in 'for' event processing loop.
|
||||
if (backend_in && frontend_out) {
|
||||
rc = forward (backend_, &backend_stats, frontend_,
|
||||
&frontend_stats, capture_, msg);
|
||||
&frontend_stats, capture_, &msg);
|
||||
CHECK_RC_EXIT_ON_FAILURE ();
|
||||
reply_processed = true;
|
||||
backend_in = frontend_out = false;
|
||||
@@ -595,7 +592,7 @@ int zmq::proxy (class socket_base_t *frontend_,
|
||||
return close_and_return (&msg, -1);
|
||||
|
||||
// Copy message to capture socket if any
|
||||
rc = capture (capture_, msg);
|
||||
rc = capture (capture_, &msg);
|
||||
if (unlikely (rc < 0))
|
||||
return close_and_return (&msg, -1);
|
||||
|
||||
@@ -628,7 +625,7 @@ int zmq::proxy (class socket_base_t *frontend_,
|
||||
if (state == active && items[0].revents & ZMQ_POLLIN
|
||||
&& (frontend_ == backend_ || itemsout[1].revents & ZMQ_POLLOUT)) {
|
||||
rc = forward (frontend_, &frontend_stats, backend_, &backend_stats,
|
||||
capture_, msg);
|
||||
capture_, &msg);
|
||||
if (unlikely (rc < 0))
|
||||
return close_and_return (&msg, -1);
|
||||
}
|
||||
@@ -637,7 +634,7 @@ int zmq::proxy (class socket_base_t *frontend_,
|
||||
&& items[1].revents & ZMQ_POLLIN
|
||||
&& itemsout[0].revents & ZMQ_POLLOUT) {
|
||||
rc = forward (backend_, &backend_stats, frontend_, &frontend_stats,
|
||||
capture_, msg);
|
||||
capture_, &msg);
|
||||
if (unlikely (rc < 0))
|
||||
return close_and_return (&msg, -1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user