[asterisk-commits] dlee: branch dlee/performance r399548 - /team/dlee/performance/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Sep 20 16:03:59 CDT 2013
Author: dlee
Date: Fri Sep 20 16:03:57 2013
New Revision: 399548
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399548
Log:
Review feedback.
* Remove the memsets from internal_ao2_ref entirely, to help malloc_debug find
fence violations.
* s/i/idx/
* alloc proper size for route tables.
* comments
Modified:
team/dlee/performance/main/astobj2.c
team/dlee/performance/main/stasis.c
team/dlee/performance/main/stasis_message_router.c
team/dlee/performance/main/taskprocessor.c
Modified: team/dlee/performance/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/performance/main/astobj2.c?view=diff&rev=399548&r1=399547&r2=399548
==============================================================================
--- team/dlee/performance/main/astobj2.c (original)
+++ team/dlee/performance/main/astobj2.c Fri Sep 20 16:03:57 2013
@@ -486,39 +486,15 @@
obj_mutex = INTERNAL_OBJ_MUTEX(user_data);
ast_mutex_destroy(&obj_mutex->mutex.lock);
-#ifdef AO2_DEBUG
- /*
- * For safety, zero-out the astobj2_lock header and also the
- * first word of the user-data, which we make sure is always
- * allocated.
- */
- memset(obj_mutex, '\0', sizeof(*obj_mutex) + sizeof(void *) );
-#endif
ast_free(obj_mutex);
break;
case AO2_ALLOC_OPT_LOCK_RWLOCK:
obj_rwlock = INTERNAL_OBJ_RWLOCK(user_data);
ast_rwlock_destroy(&obj_rwlock->rwlock.lock);
-#ifdef AO2_DEBUG
- /*
- * For safety, zero-out the astobj2_rwlock header and also the
- * first word of the user-data, which we make sure is always
- * allocated.
- */
- memset(obj_rwlock, '\0', sizeof(*obj_rwlock) + sizeof(void *) );
-#endif
ast_free(obj_rwlock);
break;
case AO2_ALLOC_OPT_LOCK_NOLOCK:
-#ifdef AO2_DEBUG
- /*
- * For safety, zero-out the astobj2 header and also the first
- * word of the user-data, which we make sure is always
- * allocated.
- */
- memset(obj, '\0', sizeof(*obj) + sizeof(void *) );
-#endif
ast_free(obj);
break;
default:
Modified: team/dlee/performance/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/performance/main/stasis.c?view=diff&rev=399548&r1=399547&r2=399548
==============================================================================
--- team/dlee/performance/main/stasis.c (original)
+++ team/dlee/performance/main/stasis.c Fri Sep 20 16:03:57 2013
@@ -284,7 +284,7 @@
if (needs_mailbox) {
/* With a small number of subscribers, a thread-per-sub is
* acceptable. If our usage changes so that we have larger
- * numbers of subscribers, we'll probably want to consier
+ * numbers of subscribers, we'll probably want to consider
* a threadpool. We had that originally, but with so few
* subscribers it was actually a performance loss instead of
* a gain.
@@ -515,7 +515,7 @@
struct dispatch *dispatch = data;
subscription_invoke(dispatch->sub, dispatch->topic, dispatch->message);
- dispatch_dtor(data);
+ dispatch_dtor(dispatch);
return 0;
}
Modified: team/dlee/performance/main/stasis_message_router.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/performance/main/stasis_message_router.c?view=diff&rev=399548&r1=399547&r2=399548
==============================================================================
--- team/dlee/performance/main/stasis_message_router.c (original)
+++ team/dlee/performance/main/stasis_message_router.c Fri Sep 20 16:03:57 2013
@@ -84,12 +84,13 @@
static int table_remove_route(struct route_table *table,
struct stasis_message_type *message_type)
{
- size_t i;
-
- for (i = 0; i < table->current_size; ++i) {
- if (table->routes[i].message_type == message_type) {
+ size_t idx;
+
+ for (idx = 0; idx < table->current_size; ++idx) {
+ if (table->routes[idx].message_type == message_type) {
ao2_cleanup(message_type);
- table->routes[i] = table->routes[--table->current_size];
+ table->routes[idx] =
+ table->routes[--table->current_size];
return 0;
}
}
@@ -99,7 +100,7 @@
static struct stasis_message_route *table_find_route(struct route_table *table,
struct stasis_message_type *message_type)
{
- size_t i;
+ size_t idx;
/* While a linear search for routes may seem very inefficient, most
* route tables have six routes or less. For such small data, it's
@@ -107,9 +108,9 @@
* tables, then we can look into containers with more efficient
* lookups.
*/
- for (i = 0; i < table->current_size; ++i) {
- if (table->routes[i].message_type == message_type) {
- return &table->routes[i];
+ for (idx = 0; idx < table->current_size; ++idx) {
+ if (table->routes[idx].message_type == message_type) {
+ return &table->routes[idx];
}
}
@@ -204,12 +205,12 @@
return NULL;
}
- router->routes = ast_calloc(1, sizeof(router->routes));
+ router->routes = ast_calloc(1, sizeof(*router->routes));
if (!router->routes) {
return NULL;
}
- router->cache_routes = ast_calloc(1, sizeof(router->routes));
+ router->cache_routes = ast_calloc(1, sizeof(*router->cache_routes));
if (!router->cache_routes) {
return NULL;
}
Modified: team/dlee/performance/main/taskprocessor.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/performance/main/taskprocessor.c?view=diff&rev=399548&r1=399547&r2=399548
==============================================================================
--- team/dlee/performance/main/taskprocessor.c (original)
+++ team/dlee/performance/main/taskprocessor.c Fri Sep 20 16:03:57 2013
@@ -675,6 +675,8 @@
/* Empty queue; return false */
if (!t) {
ao2_unlock(tps);
+
+ /* Since there was no task, no need to decrement the refcount */
return 0;
}
tps->executing = 1;
More information about the asterisk-commits
mailing list