[svn-commits] mmichelson: trunk r140489 - in /trunk: ./ apps/ channels/ funcs/ main/ res/ r...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Aug 29 12:47:18 CDT 2008


Author: mmichelson
Date: Fri Aug 29 12:47:17 2008
New Revision: 140489

URL: http://svn.digium.com/view/asterisk?view=rev&rev=140489
Log:
Merged revisions 140488 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r140488 | mmichelson | 2008-08-29 12:34:17 -0500 (Fri, 29 Aug 2008) | 22 lines

After working on the ao2_containers branch, I noticed
something a bit strange. In all cases where we provide
a callback function to ao2_container_alloc, the callback
function would only return 0 or CMP_MATCH. After inspecting
the ao2_callback() code carefully, I found that if you're
only looking for one specific item, then you should return
CMP_MATCH | CMP_STOP. Otherwise, astobj2 will continue
traversing the current bucket until the end searching for
more matches.

In cases like chan_iax2 where in 1.4, all the peers are
shoved into a single bucket, this makes for potentially
terrible performance since the entire bucket will be
traversed even if the peer is one of the first ones come
across in the bucket.

All the changes I have made were for cases where the 
callback function defined was passed to ao2_container_alloc
so that calls to ao2_find could find a unique instance
of whatever object was being stored in the container.


........

Modified:
    trunk/   (props changed)
    trunk/apps/app_queue.c
    trunk/channels/chan_console.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_sip.c
    trunk/funcs/func_dialgroup.c
    trunk/main/config.c
    trunk/main/features.c
    trunk/main/manager.c
    trunk/main/taskprocessor.c
    trunk/res/ais/lck.c
    trunk/res/res_phoneprov.c
    trunk/res/res_timing_pthread.c
    trunk/utils/hashtest2.c

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

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Fri Aug 29 12:47:17 2008
@@ -582,7 +582,7 @@
 static int queue_cmp_cb(void *obj, void *arg, int flags)
 {
 	struct call_queue *q = obj, *q2 = arg;
-	return !strcasecmp(q->name, q2->name) ? CMP_MATCH : 0;
+	return !strcasecmp(q->name, q2->name) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 static inline struct call_queue *queue_ref(struct call_queue *q)
@@ -872,7 +872,7 @@
 static int member_cmp_fn(void *obj1, void *obj2, int flags)
 {
 	struct member *mem1 = obj1, *mem2 = obj2;
-	return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH;
+	return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH | CMP_STOP;
 }
 
 /*! 

Modified: trunk/channels/chan_console.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_console.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/channels/chan_console.c (original)
+++ trunk/channels/chan_console.c Fri Aug 29 12:47:17 2008
@@ -1432,7 +1432,7 @@
 {
 	struct console_pvt *pvt = obj, *pvt2 = arg;
 
-	return !strcasecmp(pvt->name, pvt2->name) ? CMP_MATCH : 0;
+	return !strcasecmp(pvt->name, pvt2->name) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 static void stop_streams(void)

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Fri Aug 29 12:47:17 2008
@@ -1312,7 +1312,7 @@
 {
 	struct iax2_peer *peer = obj, *peer2 = arg;
 
-	return !strcmp(peer->name, peer2->name) ? CMP_MATCH : 0;
+	return !strcmp(peer->name, peer2->name) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /*!
@@ -1332,7 +1332,7 @@
 {
 	struct iax2_user *user = obj, *user2 = arg;
 
-	return !strcmp(user->name, user2->name) ? CMP_MATCH : 0;
+	return !strcmp(user->name, user2->name) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /*!
@@ -12194,7 +12194,7 @@
 	 * against a full frame or not ... */
 
 	return match(&pvt2->addr, pvt2->peercallno, pvt2->callno, pvt, 
-		pvt2->frames_received) ? CMP_MATCH : 0;
+		pvt2->frames_received) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /*! \brief Load IAX2 module, load configuraiton ---*/

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Aug 29 12:47:17 2008
@@ -1651,7 +1651,7 @@
 {
 	struct sip_peer *peer = obj, *peer2 = arg;
 
-	return !strcasecmp(peer->name, peer2->name) ? CMP_MATCH : 0;
+	return !strcasecmp(peer->name, peer2->name) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /*!
@@ -1683,11 +1683,11 @@
 	
 	if (!ast_test_flag(&peer->flags[0], SIP_INSECURE_PORT) && !ast_test_flag(&peer2->flags[0], SIP_INSECURE_PORT)) {
 		if (peer->addr.sin_port == peer2->addr.sin_port)
-			return CMP_MATCH;
+			return CMP_MATCH | CMP_STOP;
 		else
 			return 0;
 	}
-	return CMP_MATCH;
+	return CMP_MATCH | CMP_STOP;
 }
 
 /*!
@@ -1707,7 +1707,7 @@
 {
 	struct sip_pvt *pvt = obj, *pvt2 = arg;
 	
-	return !strcasecmp(pvt->callid, pvt2->callid) ? CMP_MATCH : 0;
+	return !strcasecmp(pvt->callid, pvt2->callid) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 static int temp_pvt_init(void *);

Modified: trunk/funcs/func_dialgroup.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_dialgroup.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/funcs/func_dialgroup.c (original)
+++ trunk/funcs/func_dialgroup.c Fri Aug 29 12:47:17 2008
@@ -67,9 +67,9 @@
 	struct group *g1 = obj1, *g2 = name2;
 	char *name = name2;
 	if (flags & OBJ_POINTER)
-		return strcmp(g1->name, g2->name) ? 0 : CMP_MATCH;
+		return strcmp(g1->name, g2->name) ? 0 : CMP_MATCH | CMP_STOP;
 	else
-		return strcmp(g1->name, name) ? 0 : CMP_MATCH;
+		return strcmp(g1->name, name) ? 0 : CMP_MATCH | CMP_STOP;
 }
 
 static int entry_hash_fn(const void *obj, const int flags)
@@ -83,9 +83,9 @@
 	struct group_entry *e1 = obj1, *e2 = name2;
 	char *name = name2;
 	if (flags & OBJ_POINTER)
-		return strcmp(e1->name, e2->name) ? 0 : CMP_MATCH;
+		return strcmp(e1->name, e2->name) ? 0 : CMP_MATCH | CMP_STOP;
 	else
-		return strcmp(e1->name, name) ? 0 : CMP_MATCH;
+		return strcmp(e1->name, name) ? 0 : CMP_MATCH | CMP_STOP;
 }
 
 static int dialgroup_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Modified: trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/trunk/main/config.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Fri Aug 29 12:47:17 2008
@@ -170,7 +170,7 @@
 static int hashtab_compare_strings(void *a, void *b, int flags)
 {
 	const struct inclfile *ae = a, *be = b;
-	return !strcmp(ae->fname, be->fname) ? CMP_MATCH : 0;
+	return !strcmp(ae->fname, be->fname) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 static struct ast_config_map {

Modified: trunk/main/features.c
URL: http://svn.digium.com/view/asterisk/trunk/main/features.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Fri Aug 29 12:47:17 2008
@@ -230,7 +230,7 @@
 static int parkinglot_cmp_cb(void *obj, void *arg, int flags)
 {
 	struct ast_parkinglot *parkinglot = obj, *parkinglot2 = arg;
-	return !strcasecmp(parkinglot->name, parkinglot2->name) ? CMP_MATCH : 0;
+	return !strcasecmp(parkinglot->name, parkinglot2->name) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /*!

Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Fri Aug 29 12:47:17 2008
@@ -3566,7 +3566,7 @@
 	 * the address of both the struct and the string are exactly the same. */
 	struct variable_count *vc = obj;
 	char *str = vstr;
-	return !strcmp(vc->varname, str) ? CMP_MATCH : 0;
+	return !strcmp(vc->varname, str) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /*! \brief Convert the input into XML or HTML.

Modified: trunk/main/taskprocessor.c
URL: http://svn.digium.com/view/asterisk/trunk/main/taskprocessor.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/main/taskprocessor.c (original)
+++ trunk/main/taskprocessor.c Fri Aug 29 12:47:17 2008
@@ -339,7 +339,7 @@
 {
 	struct ast_taskprocessor *lhs = obj, *rhs = arg;
 
-	return !strcasecmp(lhs->name, rhs->name) ? CMP_MATCH : 0;
+	return !strcasecmp(lhs->name, rhs->name) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /* destroy the taskprocessor */

Modified: trunk/res/ais/lck.c
URL: http://svn.digium.com/view/asterisk/trunk/res/ais/lck.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/res/ais/lck.c (original)
+++ trunk/res/ais/lck.c Fri Aug 29 12:47:17 2008
@@ -115,7 +115,7 @@
 {
 	struct lock_resource *lock1 = obj, *lock2 = arg;
 
-	return !strcasecmp(lock1->name, lock2->name) ? CMP_MATCH : 0;
+	return !strcasecmp(lock1->name, lock2->name) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 static int lock_resources_init(void *data)

Modified: trunk/res/res_phoneprov.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_phoneprov.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/res/res_phoneprov.c (original)
+++ trunk/res/res_phoneprov.c Fri Aug 29 12:47:17 2008
@@ -249,7 +249,7 @@
 {
 	const struct phone_profile *profile1 = obj, *profile2 = arg;
 
-	return !strcasecmp(profile1->name, profile2->name) ? CMP_MATCH : 0;
+	return !strcasecmp(profile1->name, profile2->name) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 static void delete_file(struct phoneprov_file *file)
@@ -295,7 +295,7 @@
 {
 	const struct http_route *route1 = obj, *route2 = arg;
 
-	return !strcmp(route1->uri, route2->uri) ? CMP_MATCH : 0;
+	return !strcmp(route1->uri, route2->uri) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 static void route_destructor(void *obj)
@@ -784,7 +784,7 @@
 {
 	const struct user *user1 = obj, *user2 = arg;
 
-	return !strcasecmp(user1->macaddress, user2->macaddress) ? CMP_MATCH : 0;
+	return !strcasecmp(user1->macaddress, user2->macaddress) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /*! \brief Free all memory associated with a user */

Modified: trunk/res/res_timing_pthread.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_timing_pthread.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/res/res_timing_pthread.c (original)
+++ trunk/res/res_timing_pthread.c Fri Aug 29 12:47:17 2008
@@ -308,7 +308,7 @@
 {
 	struct pthread_timer *timer1 = obj, *timer2 = arg;
 
-	return (timer1->pipe[PIPE_READ] == timer2->pipe[PIPE_READ]) ? CMP_MATCH : 0;
+	return (timer1->pipe[PIPE_READ] == timer2->pipe[PIPE_READ]) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /*!

Modified: trunk/utils/hashtest2.c
URL: http://svn.digium.com/view/asterisk/trunk/utils/hashtest2.c?view=diff&rev=140489&r1=140488&r2=140489
==============================================================================
--- trunk/utils/hashtest2.c (original)
+++ trunk/utils/hashtest2.c Fri Aug 29 12:47:17 2008
@@ -83,7 +83,7 @@
 static int hashtab_compare_strings(void *a, void *b, int flags)
 {
 	const struct ht_element *ae = a, *be = b;
-	return !strcmp(ae->key, be->key) ? CMP_MATCH : 0;
+	return !strcmp(ae->key, be->key) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /* random numbers */




More information about the svn-commits mailing list