summaryrefslogtreecommitdiff
path: root/src/tcp_connecter.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-02-16 10:05:01 +0900
committerMartin Sustrik <sustrik@250bpm.com>2012-02-16 10:05:01 +0900
commit2df873a435ff139cf9d1b10b666d75e6dc6da442 (patch)
tree042b0a349ca84919041fb37df7e5a3b7195d065d /src/tcp_connecter.cpp
parentb67f88a7d6322a293ac3e3be9d6df9f358509221 (diff)
Timers identified by dynamically generated handles
Timers are not longer identified by hard-wired IDs. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/tcp_connecter.cpp')
-rw-r--r--src/tcp_connecter.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/tcp_connecter.cpp b/src/tcp_connecter.cpp
index fbaaf8e..2b4f657 100644
--- a/src/tcp_connecter.cpp
+++ b/src/tcp_connecter.cpp
@@ -55,7 +55,8 @@ xs::tcp_connecter_t::tcp_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.
@@ -65,8 +66,11 @@ xs::tcp_connecter_t::tcp_connecter_t (class io_thread_t *io_thread_,
xs::tcp_connecter_t::~tcp_connecter_t ()
{
- if (wait)
- rm_timer (reconnect_timer_id);
+ if (wait) {
+ xs_assert (reconnect_timer);
+ rm_timer (reconnect_timer);
+ reconnect_timer = NULL;
+ }
if (handle_valid)
rm_fd (handle);
@@ -117,9 +121,10 @@ void xs::tcp_connecter_t::out_event (fd_t fd_)
terminate ();
}
-void xs::tcp_connecter_t::timer_event (int id_)
+void xs::tcp_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 ();
}
@@ -153,7 +158,8 @@ void xs::tcp_connecter_t::start_connecting ()
void xs::tcp_connecter_t::add_reconnect_timer()
{
- add_timer (get_new_reconnect_ivl(), reconnect_timer_id);
+ xs_assert (!reconnect_timer);
+ reconnect_timer = add_timer (get_new_reconnect_ivl());
}
int xs::tcp_connecter_t::get_new_reconnect_ivl ()