[asterisk-commits] russell: branch russell/events r103679 - /team/russell/events/main/event.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 14 13:17:21 CST 2008


Author: russell
Date: Thu Feb 14 13:17:21 2008
New Revision: 103679

URL: http://svn.digium.com/view/asterisk?view=rev&rev=103679
Log:
fix some raw IE handling when caching an event

Modified:
    team/russell/events/main/event.c

Modified: team/russell/events/main/event.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/event.c?view=diff&rev=103679&r1=103678&r2=103679
==============================================================================
--- team/russell/events/main/event.c (original)
+++ team/russell/events/main/event.c Thu Feb 14 13:17:21 2008
@@ -231,16 +231,25 @@
 	return res;
 }
 
-static int match_ie_val(struct ast_event *event, struct ast_event_ie_val *ie_val)
+static int match_ie_val(struct ast_event *event, struct ast_event_ie_val *ie_val, struct ast_event *event2)
 {
 	if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_UINT) {
-		if (ie_val->payload.uint == ast_event_get_ie_uint(event, ie_val->ie_type))
+		uint32_t val = event2 ? ast_event_get_ie_uint(event2, ie_val->ie_type) : ie_val->payload.uint;
+		if (val == ast_event_get_ie_uint(event, ie_val->ie_type))
 			return 1;
 		return 0;
 	}
 
 	if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR) {
-		if (!strcmp(ie_val->payload.str, ast_event_get_ie_str(event, ie_val->ie_type)))
+		const char *str = event2 ? ast_event_get_ie_str(event2, ie_val->ie_type) : ie_val->payload.str;
+		if (str && !strcmp(str, ast_event_get_ie_str(event, ie_val->ie_type)))
+			return 1;
+		return 0;
+	}
+
+	if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_RAW) {
+		const void *buf = event2 ? ast_event_get_ie_raw(event2, ie_val->ie_type) : ie_val->payload.raw;
+		if (buf && !memcmp(buf, ast_event_get_ie_raw(event, ie_val->ie_type), ie_val->raw_datalen))
 			return 1;
 		return 0;
 	}
@@ -264,7 +273,7 @@
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&ast_event_cache[type], event_ref, entry) {
 		struct ast_event_ie_val *ie_val;
 		AST_LIST_TRAVERSE(&event_sub->ie_vals, ie_val, entry) {
-			if (!match_ie_val(event_ref->event, ie_val))
+			if (!match_ie_val(event_ref->event, ie_val, NULL))
 				break;
 		}
 		if (!ie_val) {
@@ -800,7 +809,7 @@
 	AST_RWLIST_RDLOCK(&ast_event_cache[type]);
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&ast_event_cache[type], event_ref, entry) {
 		AST_LIST_TRAVERSE(&cache_args, cache_arg, entry) {
-			if (!match_ie_val(event_ref->event, cache_arg))
+			if (!match_ie_val(event_ref->event, cache_arg, NULL))
 				break;	
 		}
 		if (!cache_arg) {
@@ -877,7 +886,7 @@
 	AST_RWLIST_WRLOCK(&ast_event_cache[host_event_type]);
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&ast_event_cache[host_event_type], event_ref, entry) {
 		AST_LIST_TRAVERSE(&cache_args, cache_arg, entry) {
-			if (!match_ie_val(event_ref->event, cache_arg))
+			if (!match_ie_val(event_ref->event, cache_arg, event))
 				break;	
 		}
 		if (!cache_arg) {
@@ -946,7 +955,7 @@
 		AST_RWLIST_TRAVERSE(&ast_event_subs[host_event_type], sub, entry) {
 			struct ast_event_ie_val *ie_val;
 			AST_LIST_TRAVERSE(&sub->ie_vals, ie_val, entry) {
-				if (!match_ie_val(event_ref->event, ie_val))
+				if (!match_ie_val(event_ref->event, ie_val, NULL))
 					break;
 			}
 			if (ie_val)




More information about the asterisk-commits mailing list