[svn-commits] dvossel: branch dvossel/stun_monitor r282014 - in /team/dvossel/stun_monitor:...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Aug 12 12:28:52 CDT 2010


Author: dvossel
Date: Thu Aug 12 12:28:44 2010
New Revision: 282014

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=282014
Log:
addresses reviewboard comments.

pushes outbound registraions for sip and iax out of the event thread

Modified:
    team/dvossel/stun_monitor/channels/chan_iax2.c
    team/dvossel/stun_monitor/channels/chan_sip.c
    team/dvossel/stun_monitor/res/res_stun_monitor.c

Modified: team/dvossel/stun_monitor/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/stun_monitor/channels/chan_iax2.c?view=diff&rev=282014&r1=282013&r2=282014
==============================================================================
--- team/dvossel/stun_monitor/channels/chan_iax2.c (original)
+++ team/dvossel/stun_monitor/channels/chan_iax2.c Thu Aug 12 12:28:44 2010
@@ -269,6 +269,7 @@
 static char regcontext[AST_MAX_CONTEXT] = "";
 
 static struct ast_event_sub *network_change_event_subscription; /*!< subscription id for network change events */
+static int network_change_event_sched_id = -1;
 
 static int maxauthreq = 3;
 static int max_retries = 4;
@@ -1179,6 +1180,8 @@
 static int iax2_queryoption(struct ast_channel *c, int option, void *data, int *datalen);
 static int iax2_transfer(struct ast_channel *c, const char *dest);
 static int iax2_write(struct ast_channel *c, struct ast_frame *f);
+static int iax2_sched_add(struct ast_sched_thread *st, int when, ast_sched_cb callback, const void *data);
+
 static int send_trunk(struct iax2_trunk_peer *tpeer, struct timeval *now);
 static int send_command(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int);
 static int send_command_final(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int);
@@ -1257,15 +1260,26 @@
 	}
 }
 
-static void network_change_event_cb(const struct ast_event *event, void *userdata)
+static int network_change_event_sched_cb(const void *data)
 {
 	struct iax2_registry *reg;
-	ast_debug(1, "IAX, got a network change event, renewing all IAX registrations.\n");
+	network_change_event_sched_id = -1;
 	AST_LIST_LOCK(&registrations);
 	AST_LIST_TRAVERSE(&registrations, reg, entry) {
 		iax2_do_register(reg);
 	}
 	AST_LIST_UNLOCK(&registrations);
+
+	return 0;
+}
+
+static void network_change_event_cb(const struct ast_event *event, void *userdata)
+{
+	ast_debug(1, "IAX, got a network change event, renewing all IAX registrations.\n");
+	if (network_change_event_sched_id == -1) {
+		network_change_event_sched_id = iax2_sched_add(sched, 1000, network_change_event_sched_cb, NULL);
+	}
+
 }
 
 

Modified: team/dvossel/stun_monitor/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/stun_monitor/channels/chan_sip.c?view=diff&rev=282014&r1=282013&r2=282014
==============================================================================
--- team/dvossel/stun_monitor/channels/chan_sip.c (original)
+++ team/dvossel/stun_monitor/channels/chan_sip.c Thu Aug 12 12:28:44 2010
@@ -763,6 +763,7 @@
 static int global_t38_maxdatagram;                /*!< global T.38 FaxMaxDatagram override */
 
 static struct ast_event_sub *network_change_event_subscription; /*!< subscription id for network change events */
+static int network_change_event_sched_id = -1;
 
 static char used_context[AST_MAX_CONTEXT];        /*!< name of automatically created context for unloading */
 
@@ -13452,11 +13453,20 @@
 	}
 }
 
-static void network_change_event_cb(const struct ast_event *event, void *userdata)
-{
-	ast_debug(1, "SIP, got a network change event, renewing all SIP registrations.\n");
+static int network_change_event_sched_cb(const void *data)
+{
+	network_change_event_sched_id = -1;
 	sip_send_all_registers();
 	sip_send_all_mwi_subscriptions();
+	return 0;
+}
+
+static void network_change_event_cb(const struct ast_event *event, void *userdata)
+{
+	ast_debug(1, "SIP, got a network change event, renewing all SIP registrations.\n");
+	if (network_change_event_sched_id == -1) {
+		network_change_event_sched_id = ast_sched_add(sched, 1000, network_change_event_sched_cb, NULL);
+	}
 }
 
 /*! \brief Callback for the devicestate notification (SUBSCRIBE) support subsystem

Modified: team/dvossel/stun_monitor/res/res_stun_monitor.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/stun_monitor/res/res_stun_monitor.c?view=diff&rev=282014&r1=282013&r2=282014
==============================================================================
--- team/dvossel/stun_monitor/res/res_stun_monitor.c (original)
+++ team/dvossel/stun_monitor/res/res_stun_monitor.c Thu Aug 12 12:28:44 2010
@@ -62,7 +62,13 @@
 	}
 }
 
-/* \brief purge the stun socket's receive buffer before issuing a new request */
+/* \brief purge the stun socket's receive buffer before issuing a new request
+ *
+ * XXX Note that this is somewhat of a hack.  This function is essentially doing
+ * a cleanup on the socket rec buffer to handle removing any STUN responses we have not
+ * handled.  This is called before sending out a new STUN request so we don't read
+ * a latent previous response thinking it is new.
+ */
 static void stun_purge_socket(void)
 {
 	int flags = fcntl(args.stunsock, F_GETFL);




More information about the svn-commits mailing list