aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_jabber.c
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-07 09:00:44 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-07 09:00:44 +0000
commit5198798e6935478655062071f2aff46dfc65b769 (patch)
tree54277efd65885c8eb96ccdda36bef022348f6f06 /res/res_jabber.c
parentcb6441b10eeeca4ca7080af19e3bde0d016c3db1 (diff)
Issue #9738 - Make sure we can unload res_jabber. Patch by phsultan - thanks!
Due to a bug in the iksemel library, this will not work if you are using GTLS in the connection. That's being investigated. If you figure out a way to handle that without us having to patch iksemel, let us know in the bug report. Thanks. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@67993 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_jabber.c')
-rw-r--r--res/res_jabber.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/res/res_jabber.c b/res/res_jabber.c
index 481001e6b..b491f5c44 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -466,7 +466,9 @@ static void aji_log_hook(void *data, const char *xmpp, size_t size, int is_incom
/*!
* \brief The action hook parses the inbound packets, constantly running.
- * \param aji client structure, type of packet, the actual packet.
+ * \param data aji client structure
+ * \param type type of packet
+ * \param node the actual packet.
* \return IKS_OK or IKS_HOOK .
*/
static int aji_act_hook(void *data, int type, iks *node)
@@ -481,6 +483,11 @@ static int aji_act_hook(void *data, int type, iks *node)
return IKS_HOOK;
}
+ if (client->state == AJI_DISCONNECTING) {
+ ASTOBJ_UNREF(client, aji_client_destroy);
+ return IKS_HOOK;
+ }
+
pak = iks_packet(node);
if (!client->component) { /*client */
@@ -1505,6 +1512,12 @@ static void *aji_recv_loop(void *data)
}
res = iks_recv(client->p, 1);
+
+ if (client->state == AJI_DISCONNECTING) {
+ if (option_debug > 1)
+ ast_log(LOG_DEBUG, "Ending our Jabber client's thread due to a disconnect\n");
+ pthread_exit(NULL);
+ }
client->timeout--;
if (res == IKS_HOOK)
ast_log(LOG_WARNING, "JABBER: Got hook event.\n");
@@ -2400,9 +2413,9 @@ static int unload_module(void)
ast_manager_unregister("JabberSend");
ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
ASTOBJ_RDLOCK(iterator);
- if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "JABBER: %s\n", iterator->name);
- iterator->state = AJI_DISCONNECTED;
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "JABBER: Releasing and disconneing client: %s\n", iterator->name);
+ iterator->state = AJI_DISCONNECTING;
ast_aji_disconnect(iterator);
pthread_join(iterator->thread, NULL);
ASTOBJ_UNLOCK(iterator);
@@ -2410,8 +2423,6 @@ static int unload_module(void)
ASTOBJ_CONTAINER_DESTROYALL(&clients, aji_client_destroy);
ASTOBJ_CONTAINER_DESTROY(&clients);
-
- ast_log(LOG_NOTICE, "res_jabber unloaded.\n");
return 0;
}
@@ -2426,7 +2437,6 @@ static int load_module(void)
ast_register_application(app_ajistatus, aji_status_exec, ajistatus_synopsis, ajistatus_descrip);
ast_cli_register_multiple(aji_cli, sizeof(aji_cli) / sizeof(struct ast_cli_entry));
- ast_log(LOG_NOTICE, "res_jabber.so loaded.\n");
return 0;
}