From 2df873a435ff139cf9d1b10b666d75e6dc6da442 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 16 Feb 2012 10:05:01 +0900 Subject: Timers identified by dynamically generated handles Timers are not longer identified by hard-wired IDs. Signed-off-by: Martin Sustrik --- src/ipc_connecter.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/ipc_connecter.cpp') diff --git a/src/ipc_connecter.cpp b/src/ipc_connecter.cpp index 4f353bc..14d4355 100644 --- a/src/ipc_connecter.cpp +++ b/src/ipc_connecter.cpp @@ -46,7 +46,8 @@ xs::ipc_connecter_t::ipc_connecter_t (class io_thread_t *io_thread_, handle_valid (false), wait (wait_), session (session_), - current_reconnect_ivl(options.reconnect_ivl) + current_reconnect_ivl(options.reconnect_ivl), + reconnect_timer (NULL) { // TODO: set_addess should be called separately, so that the error // can be propagated. @@ -56,8 +57,10 @@ xs::ipc_connecter_t::ipc_connecter_t (class io_thread_t *io_thread_, xs::ipc_connecter_t::~ipc_connecter_t () { - if (wait) - rm_timer (reconnect_timer_id); + if (wait) { + xs_assert (reconnect_timer); + rm_timer (reconnect_timer); + } if (handle_valid) rm_fd (handle); @@ -106,9 +109,10 @@ void xs::ipc_connecter_t::out_event (fd_t fd_) terminate (); } -void xs::ipc_connecter_t::timer_event (int id_) +void xs::ipc_connecter_t::timer_event (handle_t handle_) { - xs_assert (id_ == reconnect_timer_id); + xs_assert (handle_ == reconnect_timer); + reconnect_timer = NULL; wait = false; start_connecting (); } @@ -142,7 +146,8 @@ void xs::ipc_connecter_t::start_connecting () void xs::ipc_connecter_t::add_reconnect_timer() { - add_timer (get_new_reconnect_ivl(), reconnect_timer_id); + xs_assert (reconnect_timer == NULL); + reconnect_timer = add_timer (get_new_reconnect_ivl()); } int xs::ipc_connecter_t::get_new_reconnect_ivl () -- cgit v1.2.3