Commit 5b510656 authored by sigiesec's avatar sigiesec Committed by Simon Giesecke

Problem: unreachable code around socket_base_t::add/remove_signaler

Solution: replaced by assertion
parent b77d7610
...@@ -487,32 +487,20 @@ int zmq::socket_base_t::leave (const char *group_) ...@@ -487,32 +487,20 @@ int zmq::socket_base_t::leave (const char *group_)
return rc; return rc;
} }
int zmq::socket_base_t::add_signaler (signaler_t *s_) void zmq::socket_base_t::add_signaler (signaler_t *s_)
{ {
scoped_optional_lock_t sync_lock (thread_safe ? &sync : NULL); zmq_assert (thread_safe);
if (!thread_safe) {
errno = EINVAL;
return -1;
}
scoped_lock_t sync_lock (sync);
((mailbox_safe_t *) mailbox)->add_signaler (s_); ((mailbox_safe_t *) mailbox)->add_signaler (s_);
return 0;
} }
int zmq::socket_base_t::remove_signaler (signaler_t *s_) void zmq::socket_base_t::remove_signaler (signaler_t *s_)
{ {
scoped_optional_lock_t sync_lock (thread_safe ? &sync : NULL); zmq_assert (thread_safe);
if (!thread_safe) {
errno = EINVAL;
return -1;
}
scoped_lock_t sync_lock (sync);
((mailbox_safe_t *) mailbox)->remove_signaler (s_); ((mailbox_safe_t *) mailbox)->remove_signaler (s_);
return 0;
} }
int zmq::socket_base_t::bind (const char *addr_) int zmq::socket_base_t::bind (const char *addr_)
......
...@@ -86,8 +86,8 @@ class socket_base_t : public own_t, ...@@ -86,8 +86,8 @@ class socket_base_t : public own_t,
int term_endpoint (const char *addr_); int term_endpoint (const char *addr_);
int send (zmq::msg_t *msg_, int flags_); int send (zmq::msg_t *msg_, int flags_);
int recv (zmq::msg_t *msg_, int flags_); int recv (zmq::msg_t *msg_, int flags_);
int add_signaler (signaler_t *s); void add_signaler (signaler_t *s);
int remove_signaler (signaler_t *s); void remove_signaler (signaler_t *s);
int close (); int close ();
// These functions are used by the polling mechanism to determine // These functions are used by the polling mechanism to determine
......
...@@ -130,8 +130,7 @@ int zmq::socket_poller_t::add (socket_base_t *socket_, ...@@ -130,8 +130,7 @@ int zmq::socket_poller_t::add (socket_base_t *socket_,
} }
} }
rc = socket_->add_signaler (signaler); socket_->add_signaler (signaler);
zmq_assert (rc == 0);
} }
item_t item = { item_t item = {
......
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