From c618421d6f74c0d8838c1d322304eed8321af27d Mon Sep 17 00:00:00 2001 From: Douglas Young Date: Sat, 5 May 2012 19:03:31 +0100 Subject: Return error if an invalid connection string is used This patch reintroduces the behaviour that if a tcp:// or ipc:// connection string which is invalid is passed to xs_connect, then an error is reported, instead of asserting at connection time --- src/socket_base.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/socket_base.cpp') diff --git a/src/socket_base.cpp b/src/socket_base.cpp index ec5c8bd..8ee8bd3 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -39,6 +39,7 @@ #include "tcp_listener.hpp" #include "ipc_listener.hpp" #include "tcp_connecter.hpp" +#include "ipc_connecter.hpp" #include "io_thread.hpp" #include "session_base.hpp" #include "config.hpp" @@ -491,6 +492,22 @@ int xs::socket_base_t::connect (const char *addr_) io_thread_t *thread = choose_io_thread (options.affinity); xs_assert (thread); + if (protocol == "tcp") { + tcp_connecter_t connecter (thread, NULL, options, false); + int rc = connecter.set_address (address.c_str()); + if (rc != 0) { + return -1; + } + } + + if (protocol == "ipc") { + ipc_connecter_t connecter (thread, NULL, options, false); + int rc = connecter.set_address (address.c_str()); + if (rc != 0) { + return -1; + } + } + // Create session. session_base_t *session = session_base_t::create (thread, true, this, options, protocol.c_str (), address.c_str ()); -- cgit v1.2.3