[asterisk-commits] mmichelson: branch group/pimp_my_sip r379062 - /team/group/pimp_my_sip/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 14 14:19:46 CST 2013


Author: mmichelson
Date: Mon Jan 14 14:19:42 2013
New Revision: 379062

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379062
Log:
Add some debugging and add duplicate checking when registering SDP stream handlers.


Modified:
    team/group/pimp_my_sip/res/res_sip_session.c

Modified: team/group/pimp_my_sip/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_session.c?view=diff&rev=379062&r1=379061&r2=379062
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_session.c (original)
+++ team/group/pimp_my_sip/res/res_sip_session.c Mon Jan 14 14:19:42 2013
@@ -76,8 +76,16 @@
 	SCOPED_AO2LOCK(lock, sdp_handlers);
 
 	if (handler_list) {
-		/* Already have a handler of this stream type. Just add this to the end of the list */
+		struct ast_sip_session_sdp_handler *iter;
+		/* Check if this handler is already registered for this stream type */
+		AST_LIST_TRAVERSE(&handler_list->list, iter, next) {
+			if (!strcmp(iter->id, handler->id)) {
+				ast_log(LOG_WARNING, "Handler '%s' already registered for stream type '%s'.\n", handler->id, stream_type);
+				return -1;
+			}
+		}
 		AST_LIST_INSERT_TAIL(&handler_list->list, handler, next);
+		ast_debug(1, "Registered SDP stream handler '%s' for stream type '%s'\n", handler->id, stream_type); 
 		return 0;
 	}
 
@@ -93,6 +101,7 @@
 	if (!ao2_link(sdp_handlers, handler_list)) {
 		return -1;
 	}
+	ast_debug(1, "Registered SDP stream handler '%s' for stream type '%s'\n", handler->id, stream_type); 
 	return 0;
 }
 
@@ -105,11 +114,13 @@
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&handler_list->list, iter, next) {
 		if (!strcmp(iter->id, handler->id)) {
 			AST_LIST_REMOVE_CURRENT(next);
+			ast_debug(1, "Unregistered SDP stream handler '%s' for stream type '%s'\n", handler->id, stream_type);
 		}
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
 
 	if (AST_LIST_EMPTY(&handler_list->list)) {
+		ast_debug(3, "No more handlers exist for stream type '%s'\n", stream_type);
 		return CMP_MATCH;
 	} else {
 		return CMP_STOP;




More information about the asterisk-commits mailing list