From a409072a0f72d252ce30fe8d1bdcd187673fa2cf Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 27 Mar 2007 04:14:48 +0000 Subject: [PATCH] reconnect on failure git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4774 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/libdingaling/src/libdingaling.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libs/libdingaling/src/libdingaling.c b/libs/libdingaling/src/libdingaling.c index f9d7e2acc3..d206b7988a 100644 --- a/libs/libdingaling/src/libdingaling.c +++ b/libs/libdingaling/src/libdingaling.c @@ -1423,16 +1423,18 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) break; case IKS_NET_NODNS: globals.logger(DL_LOG_DEBUG, "hostname lookup failed\n"); + microsleep(1000); + goto fail; case IKS_NET_NOCONN: globals.logger(DL_LOG_DEBUG, "connection failed\n"); + microsleep(1000); + goto fail; default: - globals.logger(DL_LOG_DEBUG, "io error %d\n", e); - microsleep(500); - continue; + globals.logger(DL_LOG_DEBUG, "io error 1 %d\n", e); + microsleep(1000); + goto fail; } - - handle->counter = opt_timeout; if (ldl_test_flag(handle, LDL_FLAG_TLS)) { launch_queue_thread(handle); @@ -1456,9 +1458,9 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) } if (IKS_OK != e) { - globals.logger(DL_LOG_DEBUG, "io error %d\n", e); - microsleep(500); - break; + globals.logger(DL_LOG_DEBUG, "io error 2 %d\n", e); + microsleep(1000); + goto fail; } @@ -1481,10 +1483,12 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) } } + fail: iks_disconnect(handle->parser); iks_parser_delete(handle->parser); ldl_clear_flag_locked(handle, LDL_FLAG_CONNECTED); ldl_clear_flag_locked(handle, LDL_FLAG_AUTHORIZED); + handle->state = CS_NEW; } ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);