Commit de339785 authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #464 from hurtonm/code_cleanup

Code cleanup
parents ec082414 ea19b7b6
...@@ -35,8 +35,6 @@ zmq::dealer_t::dealer_t (class ctx_t *parent_, uint32_t tid_, int sid_) : ...@@ -35,8 +35,6 @@ zmq::dealer_t::dealer_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
// be noone to receive the replies anyway. // be noone to receive the replies anyway.
// options.delay_on_close = false; // options.delay_on_close = false;
options.recv_identity = true;
prefetched_msg.init (); prefetched_msg.init ();
} }
...@@ -73,15 +71,7 @@ int zmq::dealer_t::xrecv (msg_t *msg_, int flags_) ...@@ -73,15 +71,7 @@ int zmq::dealer_t::xrecv (msg_t *msg_, int flags_)
return 0; return 0;
} }
// DEALER socket doesn't use identities. We can safely drop it and return fq.recv (msg_);
while (true) {
int rc = fq.recv (msg_);
if (rc != 0)
return rc;
if (likely (!(msg_->flags () & msg_t::identity)))
break;
}
return 0;
} }
bool zmq::dealer_t::xhas_in () bool zmq::dealer_t::xhas_in ()
......
...@@ -49,13 +49,13 @@ zmq::options_t::options_t () : ...@@ -49,13 +49,13 @@ zmq::options_t::options_t () :
delay_on_disconnect (true), delay_on_disconnect (true),
filter (false), filter (false),
recv_identity (false), recv_identity (false),
raw_sock (false),
tcp_keepalive (-1), tcp_keepalive (-1),
tcp_keepalive_cnt (-1), tcp_keepalive_cnt (-1),
tcp_keepalive_idle (-1), tcp_keepalive_idle (-1),
tcp_keepalive_intvl (-1), tcp_keepalive_intvl (-1),
socket_id (0) socket_id (0)
{ {
raw_sock = false;
} }
int zmq::options_t::setsockopt (int option_, const void *optval_, int zmq::options_t::setsockopt (int option_, const void *optval_,
......
...@@ -147,7 +147,6 @@ zmq::req_session_t::req_session_t (io_thread_t *io_thread_, bool connect_, ...@@ -147,7 +147,6 @@ zmq::req_session_t::req_session_t (io_thread_t *io_thread_, bool connect_,
zmq::req_session_t::~req_session_t () zmq::req_session_t::~req_session_t ()
{ {
state = options.recv_identity ? identity : bottom;
} }
int zmq::req_session_t::push_msg (msg_t *msg_) int zmq::req_session_t::push_msg (msg_t *msg_)
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdarg.h>
#include "session_base.hpp" #include "session_base.hpp"
#include "i_engine.hpp" #include "i_engine.hpp"
#include "err.hpp" #include "err.hpp"
......
...@@ -428,15 +428,11 @@ int zmq::socket_base_t::connect (const char *addr_) ...@@ -428,15 +428,11 @@ int zmq::socket_base_t::connect (const char *addr_)
// The total HWM for an inproc connection should be the sum of // The total HWM for an inproc connection should be the sum of
// the binder's HWM and the connector's HWM. // the binder's HWM and the connector's HWM.
int sndhwm; int sndhwm = 0;
int rcvhwm; if (options.sndhwm != 0 && peer.options.rcvhwm != 0)
if (options.sndhwm == 0 || peer.options.rcvhwm == 0)
sndhwm = 0;
else
sndhwm = options.sndhwm + peer.options.rcvhwm; sndhwm = options.sndhwm + peer.options.rcvhwm;
if (options.rcvhwm == 0 || peer.options.sndhwm == 0) int rcvhwm = 0;
rcvhwm = 0; if (options.rcvhwm != 0 && peer.options.sndhwm != 0)
else
rcvhwm = options.rcvhwm + peer.options.sndhwm; rcvhwm = options.rcvhwm + peer.options.sndhwm;
// Create a bi-directional pipe to connect the peers. // Create a bi-directional pipe to connect the peers.
...@@ -1034,7 +1030,7 @@ int zmq::socket_base_t::monitor (const char *addr_, int events_) ...@@ -1034,7 +1030,7 @@ int zmq::socket_base_t::monitor (const char *addr_, int events_)
// Register events to monitor // Register events to monitor
monitor_events = events_; monitor_events = events_;
monitor_socket = zmq_socket( get_ctx (), ZMQ_PAIR); monitor_socket = zmq_socket (get_ctx (), ZMQ_PAIR);
if (monitor_socket == NULL) if (monitor_socket == NULL)
return -1; return -1;
...@@ -1056,7 +1052,7 @@ void zmq::socket_base_t::event_connected (const char *addr_, int fd_) ...@@ -1056,7 +1052,7 @@ void zmq::socket_base_t::event_connected (const char *addr_, int fd_)
if (monitor_events & ZMQ_EVENT_CONNECTED) { if (monitor_events & ZMQ_EVENT_CONNECTED) {
zmq_event_t event; zmq_event_t event;
event.event = ZMQ_EVENT_CONNECTED; event.event = ZMQ_EVENT_CONNECTED;
event.data.connected.addr = (char *) addr_; event.data.connected.addr = const_cast <char *> (addr_);
event.data.connected.fd = fd_; event.data.connected.fd = fd_;
monitor_event (event); monitor_event (event);
} }
...@@ -1067,7 +1063,7 @@ void zmq::socket_base_t::event_connect_delayed (const char *addr_, int err_) ...@@ -1067,7 +1063,7 @@ void zmq::socket_base_t::event_connect_delayed (const char *addr_, int err_)
if (monitor_events & ZMQ_EVENT_CONNECT_DELAYED) { if (monitor_events & ZMQ_EVENT_CONNECT_DELAYED) {
zmq_event_t event; zmq_event_t event;
event.event = ZMQ_EVENT_CONNECT_DELAYED; event.event = ZMQ_EVENT_CONNECT_DELAYED;
event.data.connected.addr = (char *) addr_; event.data.connected.addr = const_cast <char *> (addr_);
event.data.connect_delayed.err = err_; event.data.connect_delayed.err = err_;
monitor_event (event); monitor_event (event);
} }
...@@ -1078,7 +1074,7 @@ void zmq::socket_base_t::event_connect_retried (const char *addr_, int interval_ ...@@ -1078,7 +1074,7 @@ void zmq::socket_base_t::event_connect_retried (const char *addr_, int interval_
if (monitor_events & ZMQ_EVENT_CONNECT_RETRIED) { if (monitor_events & ZMQ_EVENT_CONNECT_RETRIED) {
zmq_event_t event; zmq_event_t event;
event.event = ZMQ_EVENT_CONNECT_RETRIED; event.event = ZMQ_EVENT_CONNECT_RETRIED;
event.data.connected.addr = (char *) addr_; event.data.connected.addr = const_cast <char *> (addr_);
event.data.connect_retried.interval = interval_; event.data.connect_retried.interval = interval_;
monitor_event (event); monitor_event (event);
} }
...@@ -1089,7 +1085,7 @@ void zmq::socket_base_t::event_listening (const char *addr_, int fd_) ...@@ -1089,7 +1085,7 @@ void zmq::socket_base_t::event_listening (const char *addr_, int fd_)
if (monitor_events & ZMQ_EVENT_LISTENING) { if (monitor_events & ZMQ_EVENT_LISTENING) {
zmq_event_t event; zmq_event_t event;
event.event = ZMQ_EVENT_LISTENING; event.event = ZMQ_EVENT_LISTENING;
event.data.connected.addr = (char *) addr_; event.data.connected.addr = const_cast <char *> (addr_);
event.data.listening.fd = fd_; event.data.listening.fd = fd_;
monitor_event (event); monitor_event (event);
} }
...@@ -1100,7 +1096,7 @@ void zmq::socket_base_t::event_bind_failed (const char *addr_, int err_) ...@@ -1100,7 +1096,7 @@ void zmq::socket_base_t::event_bind_failed (const char *addr_, int err_)
if (monitor_events & ZMQ_EVENT_BIND_FAILED) { if (monitor_events & ZMQ_EVENT_BIND_FAILED) {
zmq_event_t event; zmq_event_t event;
event.event = ZMQ_EVENT_BIND_FAILED; event.event = ZMQ_EVENT_BIND_FAILED;
event.data.connected.addr = (char *) addr_; event.data.connected.addr = const_cast <char *> (addr_);
event.data.bind_failed.err = err_; event.data.bind_failed.err = err_;
monitor_event (event); monitor_event (event);
} }
...@@ -1111,7 +1107,7 @@ void zmq::socket_base_t::event_accepted (const char *addr_, int fd_) ...@@ -1111,7 +1107,7 @@ void zmq::socket_base_t::event_accepted (const char *addr_, int fd_)
if (monitor_events & ZMQ_EVENT_ACCEPTED) { if (monitor_events & ZMQ_EVENT_ACCEPTED) {
zmq_event_t event; zmq_event_t event;
event.event = ZMQ_EVENT_ACCEPTED; event.event = ZMQ_EVENT_ACCEPTED;
event.data.connected.addr = (char *) addr_; event.data.connected.addr = const_cast <char *> (addr_);
event.data.accepted.fd = fd_; event.data.accepted.fd = fd_;
monitor_event (event); monitor_event (event);
} }
...@@ -1122,7 +1118,7 @@ void zmq::socket_base_t::event_accept_failed (const char *addr_, int err_) ...@@ -1122,7 +1118,7 @@ void zmq::socket_base_t::event_accept_failed (const char *addr_, int err_)
if (monitor_events & ZMQ_EVENT_ACCEPT_FAILED) { if (monitor_events & ZMQ_EVENT_ACCEPT_FAILED) {
zmq_event_t event; zmq_event_t event;
event.event = ZMQ_EVENT_ACCEPT_FAILED; event.event = ZMQ_EVENT_ACCEPT_FAILED;
event.data.connected.addr = (char *) addr_; event.data.connected.addr = const_cast <char *> (addr_);
event.data.accept_failed.err= err_; event.data.accept_failed.err= err_;
monitor_event (event); monitor_event (event);
} }
...@@ -1133,7 +1129,7 @@ void zmq::socket_base_t::event_closed (const char *addr_, int fd_) ...@@ -1133,7 +1129,7 @@ void zmq::socket_base_t::event_closed (const char *addr_, int fd_)
if (monitor_events & ZMQ_EVENT_CLOSED) { if (monitor_events & ZMQ_EVENT_CLOSED) {
zmq_event_t event; zmq_event_t event;
event.event = ZMQ_EVENT_CLOSED; event.event = ZMQ_EVENT_CLOSED;
event.data.connected.addr = (char *) addr_; event.data.connected.addr = const_cast <char *> (addr_);
event.data.closed.fd = fd_; event.data.closed.fd = fd_;
monitor_event (event); monitor_event (event);
} }
...@@ -1144,7 +1140,7 @@ void zmq::socket_base_t::event_close_failed (const char *addr_, int err_) ...@@ -1144,7 +1140,7 @@ void zmq::socket_base_t::event_close_failed (const char *addr_, int err_)
if (monitor_events & ZMQ_EVENT_CLOSE_FAILED) { if (monitor_events & ZMQ_EVENT_CLOSE_FAILED) {
zmq_event_t event; zmq_event_t event;
event.event = ZMQ_EVENT_CLOSE_FAILED; event.event = ZMQ_EVENT_CLOSE_FAILED;
event.data.connected.addr = (char *) addr_; event.data.connected.addr = const_cast <char *> (addr_);
event.data.close_failed.err = err_; event.data.close_failed.err = err_;
monitor_event (event); monitor_event (event);
} }
...@@ -1155,7 +1151,7 @@ void zmq::socket_base_t::event_disconnected (const char *addr_, int fd_) ...@@ -1155,7 +1151,7 @@ void zmq::socket_base_t::event_disconnected (const char *addr_, int fd_)
if (monitor_events & ZMQ_EVENT_DISCONNECTED) { if (monitor_events & ZMQ_EVENT_DISCONNECTED) {
zmq_event_t event; zmq_event_t event;
event.event = ZMQ_EVENT_DISCONNECTED; event.event = ZMQ_EVENT_DISCONNECTED;
event.data.connected.addr = (char *) addr_; event.data.connected.addr = const_cast <char *> (addr_);
event.data.disconnected.fd = fd_; event.data.disconnected.fd = fd_;
monitor_event (event); monitor_event (event);
} }
......
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