[asterisk-commits] kharwell: branch kharwell/pimp_sip_security r389300 - in /team/kharwell/pimp_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon May 20 14:05:01 CDT 2013
Author: kharwell
Date: Mon May 20 14:04:57 2013
New Revision: 389300
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389300
Log:
turned the fake endpoint into a reusable global var
Modified:
team/kharwell/pimp_sip_security/include/asterisk/res_sip.h
team/kharwell/pimp_sip_security/res/res_sip.c
team/kharwell/pimp_sip_security/res/res_sip/sip_distributor.c
Modified: team/kharwell/pimp_sip_security/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_security/include/asterisk/res_sip.h?view=diff&rev=389300&r1=389299&r2=389300
==============================================================================
--- team/kharwell/pimp_sip_security/include/asterisk/res_sip.h (original)
+++ team/kharwell/pimp_sip_security/include/asterisk/res_sip.h Mon May 20 14:04:57 2013
@@ -803,6 +803,13 @@
int ast_sip_initialize_distributor(void);
/*!
+ * \brief Finalize the distributor module
+ *
+ * Unregisters pjsip modules and cleans up any allocated resources.
+ */
+void ast_sip_finalize_distributor(void);
+
+/*!
* \page Threading model for SIP
*
* There are three major types of threads that SIP will have to deal with:
Modified: team/kharwell/pimp_sip_security/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_security/res/res_sip.c?view=diff&rev=389300&r1=389299&r2=389300
==============================================================================
--- team/kharwell/pimp_sip_security/res/res_sip.c (original)
+++ team/kharwell/pimp_sip_security/res/res_sip.c Mon May 20 14:04:57 2013
@@ -1410,6 +1410,7 @@
return AST_MODULE_LOAD_SUCCESS;
error:
+ ast_sip_finalize_distributor();
ast_res_sip_destroy_configuration();
if (monitor_thread) {
stop_monitor_thread();
Modified: team/kharwell/pimp_sip_security/res/res_sip/sip_distributor.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_security/res/res_sip/sip_distributor.c?view=diff&rev=389300&r1=389299&r2=389300
==============================================================================
--- team/kharwell/pimp_sip_security/res/res_sip/sip_distributor.c (original)
+++ team/kharwell/pimp_sip_security/res/res_sip/sip_distributor.c Mon May 20 14:04:57 2013
@@ -125,19 +125,25 @@
.on_rx_request = endpoint_lookup,
};
+static struct ast_sip_endpoint *artificial_endpoint = NULL;
+
static struct ast_sip_endpoint *create_artificial_endpoint(void)
{
- struct ast_sip_endpoint *endpoint =
- ast_sorcery_alloc(ast_sip_get_sorcery(), "endpoint", NULL);
-
- if (!endpoint) {
+ if (artificial_endpoint) {
+ return artificial_endpoint;
+ }
+
+ if (!(artificial_endpoint = ast_sorcery_alloc(
+ ast_sip_get_sorcery(), "endpoint", NULL))) {
return NULL;
}
-
- endpoint->type = ARTIFICIAL;
- endpoint->num_inbound_auths = 1;
-
- return endpoint;
+ /* keep around until module is unloaded */
+ ao2_ref(artificial_endpoint, +1);
+
+ artificial_endpoint->type = ARTIFICIAL;
+ artificial_endpoint->num_inbound_auths = 1;
+
+ return artificial_endpoint;
}
static int find_always_auth_reject(void *obj, void *arg, int flags)
@@ -275,3 +281,12 @@
}
return 0;
}
+
+void ast_sip_finalize_distributor(void)
+{
+ ast_sip_unregister_service(&distributor_mod);
+ ast_sip_unregister_service(&endpoint_mod);
+ ast_sip_unregister_service(&auth_mod);
+
+ ao2_cleanup(artificial_endpoint);
+}
More information about the asterisk-commits
mailing list