From 8f9600e16ca85c36fa8fe9492ce1bb9540200037 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 20 Mar 2009 12:58:04 +0000 Subject: [PATCH] MODENDP-202 and MODENDP-204 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12680 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- Makefile.am | 2 +- libs/libdingaling/src/libdingaling.c | 14 ++++++++++++++ libs/libdingaling/src/libdingaling.h | 3 ++- src/mod/endpoints/mod_dingaling/mod_dingaling.c | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index fcab5108dd..b1a132a816 100644 --- a/Makefile.am +++ b/Makefile.am @@ -321,7 +321,7 @@ core-clean: clean_core core-install: core_install clean_core: clean-libLTLIBRARIES - + rm -f $(libfreeswitch_la_OBJECTS) install_core: install-libLTLIBRARIES core_install: install_core diff --git a/libs/libdingaling/src/libdingaling.c b/libs/libdingaling/src/libdingaling.c index 4912ecac85..ec111ed70e 100644 --- a/libs/libdingaling/src/libdingaling.c +++ b/libs/libdingaling/src/libdingaling.c @@ -1593,6 +1593,7 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) microsleep(100); } + ldl_set_flag_locked(handle, LDL_FLAG_STOPPED); } @@ -2324,6 +2325,7 @@ ldl_status ldl_handle_init(ldl_handle_t **handle, void ldl_handle_run(ldl_handle_t *handle) { + ldl_clear_flag_locked(handle, LDL_FLAG_STOPPED); ldl_set_flag_locked(handle, LDL_FLAG_RUNNING); xmpp_connect(handle, handle->login, handle->password); ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); @@ -2332,12 +2334,24 @@ void ldl_handle_run(ldl_handle_t *handle) void ldl_handle_stop(ldl_handle_t *handle) { ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); + if (ldl_test_flag(handle, LDL_FLAG_TLS)) { + int fd; + if ((fd = iks_fd(handle->parser)) > -1) { + shutdown(fd, 0x02); + } + } + + while(!ldl_test_flag(handle, LDL_FLAG_STOPPED)) { + microsleep(100); + } + } ldl_status ldl_handle_destroy(ldl_handle_t **handle) { apr_pool_t *pool = (*handle)->pool; + ldl_handle_stop(*handle); ldl_flush_queue(*handle, 1); diff --git a/libs/libdingaling/src/libdingaling.h b/libs/libdingaling/src/libdingaling.h index 45b3add497..33c644e11d 100644 --- a/libs/libdingaling/src/libdingaling.h +++ b/libs/libdingaling/src/libdingaling.h @@ -119,7 +119,8 @@ typedef enum { LDL_FLAG_AUTHORIZED = (1 << 2), LDL_FLAG_READY = (1 << 3), LDL_FLAG_CONNECTED = (1 << 4), - LDL_FLAG_QUEUE_RUNNING = (1 << 5) + LDL_FLAG_QUEUE_RUNNING = (1 << 5), + LDL_FLAG_STOPPED = (1 << 6) } ldl_flag_t; typedef enum { diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 29cd6f56f7..81bf71a119 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -1805,7 +1805,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dingaling_load) #define PRES_SYNTAX "dl_pres " #define LOGOUT_SYNTAX "dl_logout " -#define LOGIN_SYNTAX "dl_login " +#define LOGIN_SYNTAX "Existing Profile:\ndl_login profile=\nDynamic Profile:\ndl_login var1=val1;var2=val2;varN=valN\n" #define DEBUG_SYNTAX "dl_debug [true|false]" SWITCH_ADD_API(api_interface, "dl_debug", "DingaLing Debug", dl_debug, DEBUG_SYNTAX);