[asterisk-commits] russell: branch russell/iax_refcount r80298 - /team/russell/iax_refcount/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Aug 22 12:38:55 CDT 2007
Author: russell
Date: Wed Aug 22 12:38:54 2007
New Revision: 80298
URL: http://svn.digium.com/view/asterisk?view=rev&rev=80298
Log:
remove a use of sleep(), tweak some formatting, remove some debug stuff
Modified:
team/russell/iax_refcount/main/astobj2.c
Modified: team/russell/iax_refcount/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/team/russell/iax_refcount/main/astobj2.c?view=diff&rev=80298&r1=80297&r2=80298
==============================================================================
--- team/russell/iax_refcount/main/astobj2.c (original)
+++ team/russell/iax_refcount/main/astobj2.c Wed Aug 22 12:38:54 2007
@@ -21,8 +21,6 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-#include <unistd.h> /* sleep, only for debugging */
-
#include "asterisk/astobj2.h"
#include "asterisk/utils.h"
#include "asterisk/cli.h"
@@ -100,7 +98,7 @@
return NULL;
}
- p = (struct astobj2 *) ( (char *) user_data - sizeof(struct astobj2));
+ p = (struct astobj2 *) ((char *) user_data - sizeof(*p));
if (AO2_MAGIC != (p->priv_data.magic) ) {
ast_log(LOG_ERROR, "bad magic number 0x%x for %p\n", p->priv_data.magic, p);
p = NULL;
@@ -119,10 +117,9 @@
{
struct astobj2 *p = INTERNAL_OBJ(user_data);
if (p == NULL)
- if (!p)
return -1;
ast_atomic_fetchadd_int(&ao2.total_locked, 1);
- return ast_mutex_lock( &p->priv_data.lock );
+ return ast_mutex_lock(&p->priv_data.lock);
}
int ao2_unlock(void *user_data)
@@ -131,7 +128,7 @@
if (p == NULL)
return -1;
ast_atomic_fetchadd_int(&ao2.total_locked, -1);
- return ast_mutex_unlock( &p->priv_data.lock );
+ return ast_mutex_unlock(&p->priv_data.lock);
}
/*
@@ -151,15 +148,13 @@
return (obj->priv_data.ref_counter);
/* we modify with an atomic operation the reference counter */
- ret = ast_atomic_fetchadd_int( &obj->priv_data.ref_counter, delta );
+ ret = ast_atomic_fetchadd_int(&obj->priv_data.ref_counter, delta);
ast_atomic_fetchadd_int(&ao2.total_refs, delta);
current_value = ret + delta;
/* this case must never happen */
- if (current_value < 0) {
+ if (current_value < 0)
ast_log(LOG_ERROR, "refcount %d on object %p\n", current_value, user_data);
- sleep(1);
- }
if (current_value <= 0) { /* last reference, destroy the object */
if (obj->priv_data.destructor_fn != NULL)
@@ -382,10 +377,9 @@
int i, last; /* search boundaries */
void *ret = NULL;
- // ast_verbose("ao2_callback %p\n", c);
if (INTERNAL_OBJ(c) == NULL) /* safety check on the argument */
return NULL;
- if ( (flags & (OBJ_MULTIPLE | OBJ_NODATA)) == OBJ_MULTIPLE) {
+ if ((flags & (OBJ_MULTIPLE | OBJ_NODATA)) == OBJ_MULTIPLE) {
ast_log(LOG_WARNING, "multiple data return not implemented yet (flags %x)\n", flags);
return NULL;
}
More information about the asterisk-commits
mailing list