[asterisk-commits] rmudgett: trunk r323671 - in /trunk: ./ main/event.c tests/test_event.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 15 11:49:40 CDT 2011


Author: rmudgett
Date: Wed Jun 15 11:49:34 2011
New Revision: 323671

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=323671
Log:
Merged revisions 323669-323670 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r323669 | rmudgett | 2011-06-15 11:43:18 -0500 (Wed, 15 Jun 2011) | 21 lines
  
  [regression] Voicemail MWI is no longer sent.
  
  When leaving a voicemail, the MWI message is never sent.  The same thing
  happens when checking a voicemail and marking it as read.
  
  If you restart Asterisk, everything comes up at that state correctly, but
  changes to the messages in voicemail causes the light to not be set
  appropriately.  Very easy to reproduce.
  
  * Made ast_event_check_subscriber() return TRUE if there are ANY
  subscribers to an event type when there are no restricting ie values
  passed.  This allows an event being queued to be queued.
  
  (closes issue ASTERISK-18002)
  Reported by: lmadsen
  Tested by: lmadsen, irroot
  Patches:
       jira_asterisk_18002_v1.8.patch uploaded by rmudgett (License #5621)
  
  (closes issue ASTERISK-18019)
........
  r323670 | rmudgett | 2011-06-15 11:43:31 -0500 (Wed, 15 Jun 2011) | 7 lines
  
  Add a test to the event unit tests to catch ASTERISK-18002.
  
  The new tests check to see if there are ANY subscribers to the event type
  when ast_event_check_subscriber() is not passed any specific ie values.
  
  (issue ASTERISK-18002)
........

Modified:
    trunk/   (props changed)
    trunk/main/event.c
    trunk/tests/test_event.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/main/event.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/event.c?view=diff&rev=323671&r1=323670&r2=323671
==============================================================================
--- trunk/main/event.c (original)
+++ trunk/main/event.c Wed Jun 15 11:49:34 2011
@@ -444,12 +444,14 @@
 	};
 	const enum ast_event_type event_types[] = { type, AST_EVENT_ALL };
 	int i;
+	int want_specific_event;/* TRUE if looking for subscribers wanting specific parameters. */
 
 	if (type >= AST_EVENT_TOTAL) {
 		ast_log(LOG_ERROR, "%u is an invalid type!\n", type);
 		return res;
 	}
 
+	want_specific_event = 0;
 	va_start(ap, type);
 	for (ie_type = va_arg(ap, enum ast_event_ie_type);
 		ie_type != AST_EVENT_IE_END;
@@ -492,6 +494,7 @@
 		}
 
 		if (insert) {
+			want_specific_event = 1;
 			AST_LIST_INSERT_TAIL(&check_ie_vals.ie_vals, ie_value, entry);
 		} else {
 			ast_log(LOG_WARNING, "Unsupported PLTYPE(%d)\n", ie_value->ie_pltype);
@@ -501,17 +504,22 @@
 
 	for (i = 0; i < ARRAY_LEN(event_types); i++) {
 		AST_RWDLLIST_RDLOCK(&ast_event_subs[event_types[i]]);
-		AST_RWDLLIST_TRAVERSE(&ast_event_subs[event_types[i]], sub, entry) {
-			AST_LIST_TRAVERSE(&sub->ie_vals, ie_val, entry) {
-				if (!match_sub_ie_val_to_event(ie_val, &check_ie_vals)) {
-					/* The current subscription ie did not match an event ie. */
+		if (want_specific_event) {
+			AST_RWDLLIST_TRAVERSE(&ast_event_subs[event_types[i]], sub, entry) {
+				AST_LIST_TRAVERSE(&sub->ie_vals, ie_val, entry) {
+					if (!match_sub_ie_val_to_event(ie_val, &check_ie_vals)) {
+						/* The current subscription ie did not match an event ie. */
+						break;
+					}
+				}
+				if (!ie_val) {
+					/* Everything matched.  A subscriber is looking for this event. */
 					break;
 				}
 			}
-			if (!ie_val) {
-				/* Everything matched.  A subscriber is looking for this event. */
-				break;
-			}
+		} else {
+			/* Just looking to see if there are ANY subscribers to the event type. */
+			sub = AST_RWLIST_FIRST(&ast_event_subs[event_types[i]]);
 		}
 		AST_RWDLLIST_UNLOCK(&ast_event_subs[event_types[i]]);
 		if (sub) {

Modified: trunk/tests/test_event.c
URL: http://svnview.digium.com/svn/asterisk/trunk/tests/test_event.c?view=diff&rev=323671&r1=323670&r2=323671
==============================================================================
--- trunk/tests/test_event.c (original)
+++ trunk/tests/test_event.c Wed Jun 15 11:49:34 2011
@@ -312,7 +312,7 @@
 			.expected_count = 2,
 		},
 		[TEST_SUBS_CUSTOM_RAW] = {
-			.expected_count = 1,
+			.expected_count = 2,
 		},
 		[TEST_SUBS_CUSTOM_UINT] = {
 			.expected_count = 1,
@@ -344,6 +344,48 @@
 		break;
 	}
 
+	ast_test_status_update(test, "Check that NO CUSTOM subscribers exist\n");
+	sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM,
+		AST_EVENT_IE_END);
+	if (sub_res != AST_EVENT_SUB_NONE) {
+		ast_test_status_update(test, "CUSTOM subscriptions should not exist! (%d)\n",
+			sub_res);
+		res = AST_TEST_FAIL;
+	}
+
+	/*
+	 * Subscription TEST_SUBS_CUSTOM_STR:
+	 *  - allocate normally
+	 *  - subscribe to CUSTOM events with a DEVICE STR IE check
+	 */
+	ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_STR subscription\n");
+	test_subs[TEST_SUBS_CUSTOM_STR].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb,
+		test_subs_class_type_str(TEST_SUBS_CUSTOM_STR), &test_subs[TEST_SUBS_CUSTOM_STR].data,
+		AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "FOO/bar",
+		AST_EVENT_IE_END);
+	if (!test_subs[TEST_SUBS_CUSTOM_STR].sub) {
+		ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_STR subscription\n");
+		res = AST_TEST_FAIL;
+		goto return_cleanup;
+	}
+
+	if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_STR].sub),
+		test_subs_class_type_str(TEST_SUBS_CUSTOM_STR))) {
+		ast_test_status_update(test,
+			"Unexpected subscription description on TEST_SUBS_CUSTOM_STR subscription\n");
+		res = AST_TEST_FAIL;
+		goto return_cleanup;
+	}
+
+	ast_test_status_update(test, "Check that a CUSTOM subscriber exists\n");
+	sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM,
+		AST_EVENT_IE_END);
+	if (sub_res != AST_EVENT_SUB_EXISTS) {
+		ast_test_status_update(test, "A CUSTOM subscription should exist! (%d)\n",
+			sub_res);
+		res = AST_TEST_FAIL;
+	}
+
 	/*
 	 * Subscription TEST_SUBS_ALL_STR:
 	 *  - allocate normally
@@ -364,30 +406,6 @@
 		test_subs_class_type_str(TEST_SUBS_ALL_STR))) {
 		ast_test_status_update(test,
 			"Unexpected subscription description on TEST_SUBS_ALL_STR subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	/*
-	 * Subscription TEST_SUBS_CUSTOM_STR:
-	 *  - allocate normally
-	 *  - subscribe to CUSTOM events with a DEVICE STR IE check
-	 */
-	ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_STR subscription\n");
-	test_subs[TEST_SUBS_CUSTOM_STR].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb,
-		test_subs_class_type_str(TEST_SUBS_CUSTOM_STR), &test_subs[TEST_SUBS_CUSTOM_STR].data,
-		AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "FOO/bar",
-		AST_EVENT_IE_END);
-	if (!test_subs[TEST_SUBS_CUSTOM_STR].sub) {
-		ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_STR subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_STR].sub),
-		test_subs_class_type_str(TEST_SUBS_CUSTOM_STR))) {
-		ast_test_status_update(test,
-			"Unexpected subscription description on TEST_SUBS_CUSTOM_STR subscription\n");
 		res = AST_TEST_FAIL;
 		goto return_cleanup;
 	}
@@ -576,7 +594,7 @@
 	/*
 	 * Exercise the API call to check for existing subscriptions.
 	 */
-	ast_test_status_update(test, "Checking for subscribers to events\n");
+	ast_test_status_update(test, "Checking for subscribers to specific events\n");
 
 	/* Check STR matching. */
 	sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM,
@@ -676,6 +694,31 @@
 		ast_test_status_update(test, "EXISTS subscription should not exist! (%d)\n",
 			sub_res);
 		res = AST_TEST_FAIL;
+	}
+
+	ast_test_status_update(test, "Special event posting test\n");
+
+	/*
+	 * Event to check if event is even posted.
+	 *
+	 * Matching subscriptions:
+	 * TEST_SUBS_CUSTOM_RAW
+	 */
+	event = ast_event_new(AST_EVENT_CUSTOM,
+		AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "Mula",
+		AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"),
+		AST_EVENT_IE_END);
+	if (!event) {
+		ast_test_status_update(test, "Failed to create event\n");
+		res = AST_TEST_FAIL;
+		goto return_cleanup;
+	}
+	if (ast_event_queue(event)) {
+		ast_event_destroy(event);
+		event = NULL;
+		ast_test_status_update(test, "Failed to queue event\n");
+		res = AST_TEST_FAIL;
+		goto return_cleanup;
 	}
 
 	/*




More information about the asterisk-commits mailing list