[asterisk-commits] oej: branch oej/sip-subscribe-ng-1.2 r73908 - /team/oej/sip-subscribe-ng-1.2/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jul 8 09:37:00 CDT 2007


Author: oej
Date: Sun Jul  8 09:36:59 2007
New Revision: 73908

URL: http://svn.digium.com/view/asterisk?view=rev&rev=73908
Log:
Watch out for locking failures. 
Thinking about adding failures to a list to process later, but will test first on
a busy system if this is an issue.

Modified:
    team/oej/sip-subscribe-ng-1.2/channels/chan_sip.c

Modified: team/oej/sip-subscribe-ng-1.2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sip-subscribe-ng-1.2/channels/chan_sip.c?view=diff&rev=73908&r1=73907&r2=73908
==============================================================================
--- team/oej/sip-subscribe-ng-1.2/channels/chan_sip.c (original)
+++ team/oej/sip-subscribe-ng-1.2/channels/chan_sip.c Sun Jul  8 09:36:59 2007
@@ -6602,14 +6602,35 @@
 	return res;
 }
 
+/*! \brief Structure for notification queue list */
+struct notify_data_queue_item {
+	struct sip_pvt *dialog;
+	char exten[AST_MAX_EXTENSION];
+	char context[AST_MAX_CONTEXT];
+	int state;
+};
+
 /*! \brief  cb_extensionstate: Callback for the devicestate notification (SUBSCRIBE) support subsystem ---*/
 /*    If you add an "hint" priority to the extension in the dial plan,
       you will get notifications on device state changes */
 static int cb_extensionstate(char *context, char* exten, int state, void *data)
 {
 	struct sip_pvt *p = data;
-
-	ast_mutex_lock(&p->lock);
+	int lockretry = 10;
+	static int dropped_notifications = 0;
+
+	while(ast_mutex_trylock(&p->lock)) {
+		if (option_debug > 1)
+                       	ast_log(LOG_DEBUG, "Failed to grab subscription dialog lock, trying again...\n");
+		if(--lockretry)
+			usleep(5);
+	}
+	if (!lockretry) {
+		dropped_notifications++;
+		ast_log(LOG_WARNING, "Failed to grab dialog lock (#%d). Not notifyinging user about Extension Changed %s new state %s \n", dropped_notifications, exten, ast_extension_state2str(state));
+		return -1;	/* Pls retry later */
+	}
+
 
 	switch(state) {
 	case AST_EXTENSION_DEACTIVATED:	/* Retry after a while */




More information about the asterisk-commits mailing list