Commit 2cd34da1 authored by Simon Giesecke's avatar Simon Giesecke

Problem: code duplication in session_base_t::start_connecting

Solution: extract common code
parent 799fae44
...@@ -560,46 +560,44 @@ void zmq::session_base_t::start_connecting (bool wait_) ...@@ -560,46 +560,44 @@ void zmq::session_base_t::start_connecting (bool wait_)
zmq_assert (io_thread); zmq_assert (io_thread);
// Create the connecter object. // Create the connecter object.
own_t *connecter = NULL;
if (_addr->protocol == protocol_name::tcp) { if (_addr->protocol == protocol_name::tcp) {
if (!options.socks_proxy_address.empty ()) { if (!options.socks_proxy_address.empty ()) {
address_t *proxy_address = new (std::nothrow) address_t *proxy_address = new (std::nothrow)
address_t (protocol_name::tcp, options.socks_proxy_address, address_t (protocol_name::tcp, options.socks_proxy_address,
this->get_ctx ()); this->get_ctx ());
alloc_assert (proxy_address); alloc_assert (proxy_address);
socks_connecter_t *connecter = new (std::nothrow) connecter = new (std::nothrow) socks_connecter_t (
socks_connecter_t (io_thread, this, options, _addr, proxy_address, io_thread, this, options, _addr, proxy_address, wait_);
wait_);
alloc_assert (connecter);
launch_child (connecter);
} else { } else {
tcp_connecter_t *connecter = new (std::nothrow) connecter = new (std::nothrow)
tcp_connecter_t (io_thread, this, options, _addr, wait_); tcp_connecter_t (io_thread, this, options, _addr, wait_);
alloc_assert (connecter);
launch_child (connecter);
} }
return;
} }
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS \ #if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS \
&& !defined ZMQ_HAVE_VXWORKS && !defined ZMQ_HAVE_VXWORKS
if (_addr->protocol == protocol_name::ipc) { else if (_addr->protocol == protocol_name::ipc) {
ipc_connecter_t *connecter = new (std::nothrow) connecter = new (std::nothrow)
ipc_connecter_t (io_thread, this, options, _addr, wait_); ipc_connecter_t (io_thread, this, options, _addr, wait_);
alloc_assert (connecter);
launch_child (connecter);
return;
} }
#endif #endif
#if defined ZMQ_HAVE_TIPC #if defined ZMQ_HAVE_TIPC
if (_addr->protocol == protocol_name::tipc) { else if (_addr->protocol == protocol_name::tipc) {
tipc_connecter_t *connecter = new (std::nothrow) connecter = new (std::nothrow)
tipc_connecter_t (io_thread, this, options, _addr, wait_); tipc_connecter_t (io_thread, this, options, _addr, wait_);
}
#endif
#if defined ZMQ_HAVE_VMCI
else if (_addr->protocol == protocol_name::vmci) {
connecter = new (std::nothrow)
vmci_connecter_t (io_thread, this, options, _addr, wait_);
}
#endif
if (connecter != NULL) {
alloc_assert (connecter); alloc_assert (connecter);
launch_child (connecter); launch_child (connecter);
return; return;
} }
#endif
if (_addr->protocol == protocol_name::udp) { if (_addr->protocol == protocol_name::udp) {
zmq_assert (options.type == ZMQ_DISH || options.type == ZMQ_RADIO zmq_assert (options.type == ZMQ_DISH || options.type == ZMQ_RADIO
...@@ -702,15 +700,5 @@ void zmq::session_base_t::start_connecting (bool wait_) ...@@ -702,15 +700,5 @@ void zmq::session_base_t::start_connecting (bool wait_)
} }
#endif // ZMQ_HAVE_NORM #endif // ZMQ_HAVE_NORM
#if defined ZMQ_HAVE_VMCI
if (_addr->protocol == protocol_name::vmci) {
vmci_connecter_t *connecter = new (std::nothrow)
vmci_connecter_t (io_thread, this, options, _addr, wait_);
alloc_assert (connecter);
launch_child (connecter);
return;
}
#endif
zmq_assert (false); zmq_assert (false);
} }
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