[asterisk-commits] rizzo: branch rizzo/astobj2 r47895 - /team/rizzo/astobj2/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Nov 21 09:00:59 MST 2006


Author: rizzo
Date: Tue Nov 21 10:00:58 2006
New Revision: 47895

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47895
Log:
put the code handling sip_registry objects in one place.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47895&r1=47894&r2=47895
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Tue Nov 21 10:00:58 2006
@@ -1247,12 +1247,6 @@
 	ASTOBJ_CONTAINER_COMPONENTS(struct sip_peer);
 } peerl;
 
-/*! \brief  The register list: Other SIP proxys we register with and place calls to */
-static struct ast_register_list {
-	ASTOBJ_CONTAINER_COMPONENTS(struct sip_registry);
-	int recheck;
-} regl;
-
 static int temp_pvt_init(void *);
 static void temp_pvt_cleanup(void *);
 
@@ -1513,7 +1507,6 @@
 
 /*--- Internal UA client handling (outbound registrations) */
 static int ast_sip_ouraddrfor(struct in_addr *them, struct in_addr *us);
-static void sip_registry_destroy(struct sip_registry *reg);
 static int sip_register(char *value, int lineno);
 static char *regstate2str(enum sipregistrystate regstate) attribute_const;
 static int sip_reregister(void *data);
@@ -1692,10 +1685,55 @@
 	ASTOBJ_UNREF(user, sip_destroy_user);
 }
 
+/*!
+ * Support for managing the list of outbound registrations.
+ */
+
+/*! \brief  The register list: Other SIP proxys we register with and place calls to */
+struct register_list {
+	ASTOBJ_CONTAINER_COMPONENTS(struct sip_registry);
+	int recheck;
+};
+
+static struct register_list regl;
+
+/*! \brief Destroy registry object
+	Objects created with the register= statement in static configuration */
+static void sip_registry_destroy(struct sip_registry *reg)
+{
+	/* Really delete */
+	if (option_debug > 2)
+		ast_log(LOG_DEBUG, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
+
+	if (reg->register_pvt) {
+		/* Clear registry before destroying to ensure
+		   we don't get reentered trying to grab the registry lock */
+		reg->register_pvt->registry = NULL;
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
+		reg->register_pvt = sip_destroy(reg->register_pvt);
+	}
+	if (reg->expire > -1)
+		ast_sched_del(sched, reg->expire);
+	if (reg->timeout > -1)
+		ast_sched_del(sched, reg->timeout);
+	ast_string_field_free_pools(reg);
+	regobjs--;
+	free(reg);
+}
+
 static void unref_registry(struct sip_registry *reg)
 {
 	ASTOBJ_UNREF(reg, sip_registry_destroy);
 }
+
+static void registry_destroy_all(void)
+{
+	ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy);
+	if (option_debug > 3)
+		ast_log(LOG_DEBUG, "--------------- Done destroying registry list\n");
+}
+
 
 /*! \brief Interface structure with callbacks used to connect to UDPTL module*/
 static struct ast_udptl_protocol sip_udptl = {
@@ -3046,31 +3084,6 @@
 		p->initid = ast_sched_add(sched, SIP_TRANS_TIMEOUT, auto_congest, pvt_ref(p));
 	}
 	return res;
-}
-
-/*! \brief Destroy registry object
-	Objects created with the register= statement in static configuration */
-static void sip_registry_destroy(struct sip_registry *reg)
-{
-	/* Really delete */
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
-
-	if (reg->register_pvt) {
-		/* Clear registry before destroying to ensure
-		   we don't get reentered trying to grab the registry lock */
-		reg->register_pvt->registry = NULL;
-		if (option_debug > 2)
-			ast_log(LOG_DEBUG, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
-		reg->register_pvt = sip_destroy(reg->register_pvt);
-	}
-	if (reg->expire > -1)
-		ast_sched_del(sched, reg->expire);
-	if (reg->timeout > -1)
-		ast_sched_del(sched, reg->timeout);
-	ast_string_field_free_pools(reg);
-	regobjs--;
-	free(reg);
 }
 
 /*!
@@ -17393,9 +17406,7 @@
 	ASTOBJ_CONTAINER_DESTROYALL(&userl, sip_destroy_user);
 	if (option_debug > 3)
 		ast_log(LOG_DEBUG, "--------------- Done destroying user list\n");
-	ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy);
-	if (option_debug > 3)
-		ast_log(LOG_DEBUG, "--------------- Done destroying registry list\n");
+	registry_destroy_all();
 	ASTOBJ_CONTAINER_MARKALL(&peerl);
 	reload_config(reason);
 
@@ -17652,7 +17663,7 @@
 	ASTOBJ_CONTAINER_DESTROY(&userl);
 	ASTOBJ_CONTAINER_DESTROYALL(&peerl, sip_destroy_peer);
 	ASTOBJ_CONTAINER_DESTROY(&peerl);
-	ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy);
+	registry_destroy_all();
 	ASTOBJ_CONTAINER_DESTROY(&regl);
 
 	clear_realm_authentication(authl);



More information about the asterisk-commits mailing list