[asterisk-commits] file: branch file/res_xmpp r368032 - in /team/file/res_xmpp: include/asterisk...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 31 10:37:34 CDT 2012


Author: file
Date: Thu May 31 10:37:28 2012
New Revision: 368032

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=368032
Log:
Add the ability to reload and remove clients.

Modified:
    team/file/res_xmpp/include/asterisk/xmpp.h
    team/file/res_xmpp/res/res_xmpp.c

Modified: team/file/res_xmpp/include/asterisk/xmpp.h
URL: http://svnview.digium.com/svn/asterisk/team/file/res_xmpp/include/asterisk/xmpp.h?view=diff&rev=368032&r1=368031&r2=368032
==============================================================================
--- team/file/res_xmpp/include/asterisk/xmpp.h (original)
+++ team/file/res_xmpp/include/asterisk/xmpp.h Thu May 31 10:37:28 2012
@@ -138,13 +138,13 @@
 	int port;
 	int timeout;
 	int message_timeout;
-	unsigned int authorized:1;
 	struct ast_flags flags;
 	struct ao2_container *buddies;
 	AST_LIST_HEAD(, ast_xmpp_message) messages;
 	pthread_t thread;
 	int priority;
 	enum ikshowtype status;
+	unsigned int destroy:1;
 };
 
 /*!

Modified: team/file/res_xmpp/res/res_xmpp.c
URL: http://svnview.digium.com/svn/asterisk/team/file/res_xmpp/res/res_xmpp.c?view=diff&rev=368032&r1=368031&r2=368032
==============================================================================
--- team/file/res_xmpp/res/res_xmpp.c (original)
+++ team/file/res_xmpp/res/res_xmpp.c Thu May 31 10:37:28 2012
@@ -3002,7 +3002,6 @@
 
 	client->state = XMPP_STATE_DISCONNECTED;
 	client->timeout = 50;
-	client->authorized = 0;
 	iks_parser_reset(client->parser);
 
 	if (!client->filter && !(client->filter = iks_filter_new())) {
@@ -3299,6 +3298,7 @@
 	ao2_lock(client);
 
 	wascomponent = ast_test_flag(&client->flags, XMPP_COMPONENT);
+	client->destroy = 0;
 
 	for (v = ast_variable_browse(cfg, category); v; v = v->next) {
 		CV_START(v->name, v->value);
@@ -3368,6 +3368,24 @@
 	ao2_ref(client, -1);
 }
 
+/*! \brief Set client to destroy */
+static int xmpp_client_set_destroy(void *obj, void *arg, int flags)
+{
+	struct ast_xmpp_client *client = obj;
+
+	client->destroy = 1;
+
+	return 0;
+}
+
+/*! \brief Check whether client should be destroyed or not */
+static int xmpp_client_check_destroy(void *obj, void *arg, int flags)
+{
+	struct ast_xmpp_client *client = obj;
+
+	return client->destroy ? CMP_MATCH : 0;
+}
+
 /*! \brief Internal function which loads (or reloads) the configuration file */
 static int xmpp_load_config(int reload)
 {
@@ -3390,6 +3408,8 @@
 	}
 
 	ast_set_flag(&generalflags, XMPP_AUTOREGISTER | XMPP_AUTOACCEPT | XMPP_USETLS | XMPP_USESASL | XMPP_KEEPALIVE);
+
+	ao2_callback(clients, OBJ_NODATA, xmpp_client_set_destroy, NULL);
 
 	for (cat = ast_category_browse(cfg, NULL); cat; cat = ast_category_browse(cfg, cat)) {
 		if (!strcasecmp(cat, "general")) {
@@ -3398,6 +3418,8 @@
 			store_config_client(cfg, cat);
 		}
 	}
+
+	ao2_callback(clients, OBJ_UNLINK | OBJ_NODATA, xmpp_client_check_destroy, NULL);
 
 	ast_config_destroy(cfg);
 
@@ -4042,7 +4064,7 @@
 
 static int reload(void)
 {
-	return 0;
+	return xmpp_load_config(1);
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Asterisk XMPP Interface",




More information about the asterisk-commits mailing list