diff options
| -rw-r--r-- | src/ipc_connecter.cpp | 13 | ||||
| -rw-r--r-- | src/ipc_connecter.hpp | 7 | ||||
| -rw-r--r-- | src/tcp_connecter.cpp | 10 | ||||
| -rw-r--r-- | src/tcp_connecter.hpp | 7 | 
4 files changed, 17 insertions, 20 deletions
| diff --git a/src/ipc_connecter.cpp b/src/ipc_connecter.cpp index 14d4355..f6a01c3 100644 --- a/src/ipc_connecter.cpp +++ b/src/ipc_connecter.cpp @@ -43,7 +43,7 @@ xs::ipc_connecter_t::ipc_connecter_t (class io_thread_t *io_thread_,      own_t (io_thread_, options_),      io_object_t (io_thread_),      s (retired_fd), -    handle_valid (false), +    handle (NULL),      wait (wait_),      session (session_),      current_reconnect_ivl(options.reconnect_ivl), @@ -61,8 +61,10 @@ xs::ipc_connecter_t::~ipc_connecter_t ()          xs_assert (reconnect_timer);          rm_timer (reconnect_timer);      } -    if (handle_valid) +    if (handle) {          rm_fd (handle); +        handle = NULL; +    }      if (s != retired_fd)          close (); @@ -87,8 +89,9 @@ void xs::ipc_connecter_t::in_event (fd_t fd_)  void xs::ipc_connecter_t::out_event (fd_t fd_)  {      fd_t fd = connect (); +    xs_assert (handle);      rm_fd (handle); -    handle_valid = false; +    handle = NULL;      //  Handle the error condition by attempt to reconnect.      if (fd == retired_fd) { @@ -124,16 +127,16 @@ void xs::ipc_connecter_t::start_connecting ()      //  Connect may succeed in synchronous manner.      if (rc == 0) { +        xs_assert (!handle);          handle = add_fd (s); -        handle_valid = true;          out_event (s);          return;      }      //  Connection establishment may be delayed. Poll for its completion.      else if (rc == -1 && errno == EAGAIN) { +        xs_assert (!handle);          handle = add_fd (s); -        handle_valid = true;          set_pollout (handle);          return;      } diff --git a/src/ipc_connecter.hpp b/src/ipc_connecter.hpp index 02b7382..2a8e8e4 100644 --- a/src/ipc_connecter.hpp +++ b/src/ipc_connecter.hpp @@ -93,13 +93,10 @@ namespace xs          //  Underlying socket.          fd_t s; -        //  Handle corresponding to the listening socket. +        //  Handle corresponding to the listening socket or NULL if the socket +        //  is not registered with the poller.          handle_t handle; -        //  If true file descriptor is registered with the poller and 'handle' -        //  contains valid value. -        bool handle_valid; -          //  If true, connecter is waiting a while before trying to connect.          bool wait; diff --git a/src/tcp_connecter.cpp b/src/tcp_connecter.cpp index 2b4f657..5007570 100644 --- a/src/tcp_connecter.cpp +++ b/src/tcp_connecter.cpp @@ -52,7 +52,7 @@ xs::tcp_connecter_t::tcp_connecter_t (class io_thread_t *io_thread_,      own_t (io_thread_, options_),      io_object_t (io_thread_),      s (retired_fd), -    handle_valid (false), +    handle (NULL),      wait (wait_),      session (session_),      current_reconnect_ivl(options.reconnect_ivl), @@ -71,7 +71,7 @@ xs::tcp_connecter_t::~tcp_connecter_t ()          rm_timer (reconnect_timer);          reconnect_timer = NULL;      } -    if (handle_valid) +    if (handle)          rm_fd (handle);      if (s != retired_fd) @@ -98,7 +98,7 @@ void xs::tcp_connecter_t::out_event (fd_t fd_)  {      fd_t fd = connect ();      rm_fd (handle); -    handle_valid = false; +    handle = NULL;      //  Handle the error condition by attempt to reconnect.      if (fd == retired_fd) { @@ -136,16 +136,16 @@ void xs::tcp_connecter_t::start_connecting ()      //  Connect may succeed in synchronous manner.      if (rc == 0) { +        xs_assert (!handle);          handle = add_fd (s); -        handle_valid = true;          out_event (s);          return;      }      //  Connection establishment may be delayed. Poll for its completion.      else if (rc == -1 && errno == EAGAIN) { +        xs_assert (!handle);          handle = add_fd (s); -        handle_valid = true;          set_pollout (handle);          return;      } diff --git a/src/tcp_connecter.hpp b/src/tcp_connecter.hpp index b86c2d5..7164fa2 100644 --- a/src/tcp_connecter.hpp +++ b/src/tcp_connecter.hpp @@ -90,13 +90,10 @@ namespace xs          //  Underlying socket.          fd_t s; -        //  Handle corresponding to the listening socket. +        //  Handle corresponding to the listening socket or NULL if the socket +        //  is not registered with the poller.          handle_t handle; -        //  If true file descriptor is registered with the poller and 'handle' -        //  contains valid value. -        bool handle_valid; -          //  If true, connecter is waiting a while before trying to connect.          bool wait; | 
