[asterisk-commits] schmidts: branch schmidts/unleash-the-beast r337971 - /team/schmidts/unleash-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 26 09:37:43 CDT 2011


Author: schmidts
Date: Mon Sep 26 09:37:39 2011
New Revision: 337971

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=337971
Log:
fixes problem with ast_str handling, and add initial check for 
device container. change iterator name from i to dev_iter.


Modified:
    team/schmidts/unleash-the-beast/main/pbx.c

Modified: team/schmidts/unleash-the-beast/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/schmidts/unleash-the-beast/main/pbx.c?view=diff&rev=337971&r1=337970&r2=337971
==============================================================================
--- team/schmidts/unleash-the-beast/main/pbx.c (original)
+++ team/schmidts/unleash-the-beast/main/pbx.c Mon Sep 26 09:37:39 2011
@@ -4361,10 +4361,10 @@
 static int handle_statechange(void *datap)
 {
 	struct ast_hint *hint;
-	struct ast_str *hint_app = NULL;
+	struct ast_str *hint_app;
 	struct ast_hintdevice *device, *cmpdevice;
 	struct statechange *sc = datap;
-	struct ao2_iterator *i;
+	struct ao2_iterator *dev_iter;
 	struct ao2_iterator cb_iter;
 	char context_name[AST_MAX_CONTEXT];
 	char exten_name[AST_MAX_EXTENSION];
@@ -4378,22 +4378,32 @@
 	strcpy(cmpdevice->hintdevice, sc->dev);
 
 	ast_mutex_lock(&context_merge_lock);/* Hold off ast_merge_contexts_and_delete */
-	i = ao2_t_callback(hintdevices,
+	dev_iter = ao2_t_callback(hintdevices,
 		OBJ_POINTER | OBJ_MULTIPLE,
 		hintdevice_cmp_multiple,
 		cmpdevice,
 		"find devices in container");
-//	i = ao2_iterator_init(hints, 0);
-	for (; (device = ao2_iterator_next(i)); ao2_ref(device, -1)) {
+	
+	if (!dev_iter) {
+		ast_mutex_unlock(&context_merge_lock);
+		ast_free(sc);
+		return -1;
+	}
+	hint_app = ast_str_create(1024);
+	if (!hint_app) {
+		ast_free(sc);
+		return -1;
+	}
+	for (; (device = ao2_iterator_next(dev_iter)); ao2_ref(device, -1)) {
 		struct ast_state_cb *state_cb;
 		int state;
 		if (!device->hint) {
 			continue;
 		}
 
+		hint = device->hint;
 		ao2_lock(hints);
 		ao2_lock(hint);
-		hint = device->hint;
 
 		if (!hint->exten) {
 			/* The extension has already been destroyed */
@@ -4455,7 +4465,7 @@
 		}
 		ao2_iterator_destroy(&cb_iter);
 	}
-	ao2_iterator_destroy(i);
+	ao2_iterator_destroy(dev_iter);
 	ast_mutex_unlock(&context_merge_lock);
 
 	if (hint_app) {




More information about the asterisk-commits mailing list