[asterisk-commits] murf: branch murf/bug11210 r94815 - in /team/murf/bug11210: apps/ channels/ f...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Dec 26 16:16:03 CST 2007
Author: murf
Date: Wed Dec 26 16:16:03 2007
New Revision: 94815
URL: http://svn.digium.com/view/asterisk?view=rev&rev=94815
Log:
refactored the stuff I did to track refcounts in astobj2. Now, sources that are not using the feature require no changes. Sources that do/could simply rename all routines from ao2_alloc, ao2_ref, ao2_link, ao2_unlink, ao2_iterator_next, ao2_callback, ao2_container_alloc, and ao2_find to: ao2_t_alloc, ao2_t_ref, ao2_t_link, ao2_t_unlink, ao2_t_iterator_next, ao2_t_callback, ao2_t_container_alloc, ao2_t_find, respectively, and add a trailing 'tag' arg, which is a string describing what/why you are doing. This tag will help you pair ref ops vs unref ops. To compile in the feature, put #define REF_DEBUG 1 above your #include 'astobj2'... a file /tmp/refs will be created; if you do a 'sort -k 1,2 /tmp/refs > r4' on that file, it will sort by the object address, and you'll get each object's history nicely grouped. Don't forget to remove the /tmp/refs file between asterisk runs. Try to end your run with 'stop gracefully', so your objects have a chance to be unrefd and destroyed.
Modified:
team/murf/bug11210/apps/app_queue.c
team/murf/bug11210/channels/chan_iax2.c
team/murf/bug11210/channels/chan_sip.c
team/murf/bug11210/funcs/func_dialgroup.c
team/murf/bug11210/include/asterisk/astobj2.h
team/murf/bug11210/main/astobj2.c
team/murf/bug11210/main/config.c
team/murf/bug11210/main/manager.c
team/murf/bug11210/utils/hashtest2.c
Modified: team/murf/bug11210/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/apps/app_queue.c?view=diff&rev=94815&r1=94814&r2=94815
==============================================================================
--- team/murf/bug11210/apps/app_queue.c (original)
+++ team/murf/bug11210/apps/app_queue.c Wed Dec 26 16:16:03 2007
@@ -92,27 +92,6 @@
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/global_datastores.h"
-
-#define ao2_ref(arg1, arg2) ao2_ref_debug((arg1), (arg2), "app_queue", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-int ao2_ref_debug(void *o, int delta, char *tag, char *file, int line, const char *funcname);
-#define ao2_link(arg1,arg2) ao2_link_debug((arg1), (arg2), "app_queue", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-int ao2_link_debug(struct ao2_container *c, void *o2, char *tag, char *file, int line, const char *funcname);
-#define ao2_unlink(arg1, arg2) ao2_unlink_debug((arg1), (arg2), "app_queue", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void *ao2_unlink_debug(struct ao2_container *c, void *obj, char *tag, char *file, int line, const char *funcname);
-#define ao2_alloc(arg1,arg2) ao2_alloc_debug((arg1), (arg2), "app_queue", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void *ao2_alloc_debug(const size_t data_size, ao2_destructor_fn destructor_fn, char *tag, char *file, int line, const char *funcname);
-#define ao2_container_alloc(arg1,arg2,arg3) ao2_container_alloc_debug((arg1), (arg2), (arg3), "app_queue", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-struct ao2_container *ao2_container_alloc_debug(const uint n_buckets,
- ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn,
- char *tag, char *file, int line, const char *funcname);
-#define ao2_callback(arg1,arg2,arg3,arg4) ao2_callback_debug((arg1), (arg2), (arg3), (arg4), "app_queue", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void *ao2_callback_debug(struct ao2_container *c, enum search_flags flags,
- ao2_callback_fn *cb_fn, void *arg, char *tag,
- char *file, int line, const char *funcname);
-#define ao2_find(arg1,arg2,arg3) ao2_find_debug((arg1), (arg2), (arg3), "app_queue", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void *ao2_find_debug(struct ao2_container *c, void *arg, enum search_flags flags, char *tag, char *file, int line, const char *funcname);
-#define ao2_iterator_next(arg1) ao2_iterator_next_debug((arg1), "app_queue", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void *ao2_iterator_next_debug(struct ao2_iterator *a, char *tag, char *file, int line, const char *funcname);
enum {
QUEUE_STRATEGY_RINGALL = 0,
Modified: team/murf/bug11210/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_iax2.c?view=diff&rev=94815&r1=94814&r2=94815
==============================================================================
--- team/murf/bug11210/channels/chan_iax2.c (original)
+++ team/murf/bug11210/channels/chan_iax2.c Wed Dec 26 16:16:03 2007
@@ -88,27 +88,6 @@
#include "asterisk/linkedlists.h"
#include "asterisk/event.h"
#include "asterisk/astobj2.h"
-#define ao2_ref(arg1,arg2) ao2_ref_debug((arg1), (arg2), "IAX", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-int ao2_ref_debug(void *o, int delta, char *tag, char *file, int line, const char *funcname);
-#define ao2_link(arg1,arg2) ao2_link_debug((arg1), (arg2), "IAX", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-int ao2_link_debug(struct ao2_container *c, void *o2, char *tag, char *file, int line, const char *funcname);
-#define ao2_unlink(arg1, arg2) ao2_unlink_debug((arg1), (arg2), "IAX", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void *ao2_unlink_debug(struct ao2_container *c, void *obj, char *tag, char *file, int line, const char *funcname);
-#define ao2_alloc(arg1,arg2) ao2_alloc_debug((arg1), (arg2), "IAX", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void *ao2_alloc_debug(const size_t data_size, ao2_destructor_fn destructor_fn, char *tag, char *file, int line, const char *funcname);
-#define ao2_container_alloc(arg1,arg2,arg3) ao2_container_alloc_debug((arg1), (arg2), (arg3), "IAX", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-struct ao2_container *ao2_container_alloc_debug(const uint n_buckets,
- ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn,
- char *tag, char *file, int line, const char *funcname);
-#define ao2_iterator_next(arg1) ao2_iterator_next_debug((arg1), "IAX", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void *ao2_iterator_next_debug(struct ao2_iterator *a, char *tag, char *file, int line, const char *funcname);
-
-#define ao2_callback(arg1,arg2,arg3,arg4) ao2_callback_debug((arg1), (arg2), (arg3), (arg4), "IAX", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void *ao2_callback_debug(struct ao2_container *c, enum search_flags flags,
- ao2_callback_fn *cb_fn, void *arg, char *tag,
- char *file, int line, const char *funcname);
-#define ao2_find(arg1,arg2,arg3) ao2_find_debug((arg1), (arg2), (arg3), "IAX", __FILE__, __LINE__, __PRETTY_FUNCTION__)
-void *ao2_find_debug(struct ao2_container *c, void *arg, enum search_flags flags, char *tag, char *file, int line, const char *funcname);
#include "iax2.h"
#include "iax2-parser.h"
Modified: team/murf/bug11210/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_sip.c?view=diff&rev=94815&r1=94814&r2=94815
==============================================================================
--- team/murf/bug11210/channels/chan_sip.c (original)
+++ team/murf/bug11210/channels/chan_sip.c Wed Dec 26 16:16:03 2007
@@ -124,7 +124,7 @@
#include "asterisk/utils.h"
#include "asterisk/file.h"
#include "asterisk/astobj.h"
-#define REF_DEBUG 1
+/* #define REF_DEBUG 1 */
#include "asterisk/astobj2.h"
#include "asterisk/dnsmgr.h"
#include "asterisk/devicestate.h"
@@ -1234,7 +1234,7 @@
static struct sip_pvt *dialog_ref(struct sip_pvt *p, char *tag)
{
if (p)
- ao2_ref(p,1,tag);
+ ao2_ref(p,1);
else
ast_log(LOG_ERROR,"Attempt to Ref a null pointer\n");
return p;
@@ -1243,7 +1243,7 @@
static struct sip_pvt *dialog_unref(struct sip_pvt *p, char *tag)
{
if (p)
- ao2_ref(p,-1, tag);
+ ao2_ref(p,-1);
return NULL;
}
#endif
@@ -2068,21 +2068,21 @@
*/
static void *unref_peer(struct sip_peer *peer, char *tag)
{
- int rc = ao2_ref(peer,-1,tag);
+ int rc = ao2_t_ref(peer,-1,tag);
ast_log(LOG_NOTICE,"Unref peer %s prev refcount=%d\n", peer->name, rc);
return NULL;
}
static void *unref_user(struct sip_user *user, char *tag)
{
- int rc = ao2_ref(user,-1, tag);
+ int rc = ao2_t_ref(user,-1, tag);
ast_log(LOG_NOTICE,"Unref user %s prev refcount=%d\n", user->name, rc);
return NULL;
}
static struct sip_peer *ref_peer(struct sip_peer *peer, char *tag)
{
- int rc = ao2_ref(peer,1,tag);
+ int rc = ao2_t_ref(peer,1,tag);
ast_log(LOG_NOTICE,"Ref peer %s prev refcount=%d\n", peer->name, rc);
return peer;
}
@@ -2090,7 +2090,7 @@
static void *dialog_unlink_all(struct sip_pvt *dialog, int lockowner, int lockdialoglist)
{
- ao2_unlink(dialogs, dialog, "unlinking dialog via ao2_unlink");
+ ao2_t_unlink(dialogs, dialog, "unlinking dialog via ao2_unlink");
/* Unlink us from the owner (channel) if we have one */
if (dialog->owner) {
@@ -3468,8 +3468,8 @@
really, really, we should be incr. its refcount right here, but I guess, since
peers hang around until module unload time anyway, it's not worth the trouble */
}
- ao2_link(peers, peer, "link peer into peers table");
- ao2_link(peers_by_ip, peer, "link peer into peers_by_ip table");
+ ao2_t_link(peers, peer, "link peer into peers table");
+ ao2_t_link(peers_by_ip, peer, "link peer into peers_by_ip table");
} else {
peer->is_realtime = 1;
}
@@ -3512,12 +3512,12 @@
if (peer)
{
ast_copy_string(tmp_peer.name, peer, sizeof(tmp_peer.name));
- p = ao2_find(peers, &tmp_peer, OBJ_POINTER,"ao2_find in peers table");
+ p = ao2_t_find(peers, &tmp_peer, OBJ_POINTER,"ao2_find in peers table");
} else if (sin) { /* search by addr? */
tmp_peer.addr.sin_addr.s_addr = sin->sin_addr.s_addr;
tmp_peer.addr.sin_port = sin->sin_port;
ast_log(LOG_NOTICE,"Searching for peer %s by IP addr/port = %d/%d\n", peer, sin->sin_addr.s_addr, sin->sin_port);
- p = ao2_find(peers_by_ip, &tmp_peer, OBJ_POINTER,"ao2_find in peers_by_ip table"); /* WAS: p = ASTOBJ_CONTAINER_FIND_FULL(&peerl, sin, name, sip_addr_hashfunc, 1, sip_addrcmp); */
+ p = ao2_t_find(peers_by_ip, &tmp_peer, OBJ_POINTER,"ao2_find in peers_by_ip table"); /* WAS: p = ASTOBJ_CONTAINER_FIND_FULL(&peerl, sin, name, sip_addr_hashfunc, 1, sip_addrcmp); */
}
@@ -3530,7 +3530,7 @@
ast_log(LOG_NOTICE,"Did not find peer %s / addr=%d port=%d\n", peer, sin->sin_addr.s_addr, sin->sin_port);
if (p) {
- rc = ao2_ref(p,0,"");
+ rc = ao2_t_ref(p,0,"");
ast_log(LOG_NOTICE,"FOUND peer %s refcount = %d\n", peer, rc);
}
return p;
@@ -3590,7 +3590,7 @@
if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
ast_set_flag(&user->flags[1], SIP_PAGE2_RTCACHEFRIENDS);
suserobjs++;
- ao2_link(users, user, "link user into users table");
+ ao2_t_link(users, user, "link user into users table");
} else {
/* Move counter from s to r... */
suserobjs--;
@@ -3611,7 +3611,7 @@
struct sip_user *u;
ast_copy_string(tmp.name, name, sizeof(tmp.name));
- u = ao2_find(users, &tmp, OBJ_POINTER, "ao2_find in users table");
+ u = ao2_t_find(users, &tmp, OBJ_POINTER, "ao2_find in users table");
if (!u && realtime)
u = realtime_user(name);
@@ -3740,9 +3740,9 @@
c = strchr(tmpcall, '@');
if (c) {
*c = '\0';
- ao2_unlink(dialogs,dialog,"About to change the callid -- remove the old name");
+ ao2_t_unlink(dialogs,dialog,"About to change the callid -- remove the old name");
ast_string_field_build(dialog, callid, "%s@%s", tmpcall, peer->fromdomain);
- ao2_link(dialogs,dialog,"New dialog callid -- inserted back into table");
+ ao2_t_link(dialogs,dialog,"New dialog callid -- inserted back into table");
ast_log(LOG_NOTICE,"============================================================Changed Dialog name to %s\n", dialog->callid);
}
}
@@ -5389,11 +5389,11 @@
struct sip_pvt *p;
ast_log(LOG_NOTICE,"allocating PVT for %s\n", callid);
- if (!(p = ao2_alloc(sizeof(*p), sip_destroy_fn, "allocate a dialog(pvt) struct")))
+ if (!(p = ao2_t_alloc(sizeof(*p), sip_destroy_fn, "allocate a dialog(pvt) struct")))
return NULL;
if (ast_string_field_init(p, 512)) {
- ao2_ref(p,-1,"failed to string_field_init, drop p");
+ ao2_t_ref(p,-1,"failed to string_field_init, drop p");
return NULL;
}
@@ -5448,7 +5448,7 @@
ast_variables_destroy(p->chanvars);
p->chanvars = NULL;
}
- ao2_ref(p,-1,"failed to create RTP audio session, drop p");
+ ao2_t_ref(p,-1,"failed to create RTP audio session, drop p");
return NULL;
}
ast_rtp_setqos(p->rtp, global_tos_audio, global_cos_audio, "SIP RTP");
@@ -5512,7 +5512,7 @@
/* Add to active dialog list */
- ao2_link(dialogs, p, "link pvt into dialogs table");
+ ao2_t_link(dialogs, p, "link pvt into dialogs table");
ast_log(LOG_NOTICE,"***Just linked %s into dialogs table\n", p->callid);
ast_debug(1, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : p->callid, sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
@@ -5648,9 +5648,9 @@
int rc;
ast_string_field_set(&tmp_dialog, callid, callid);
- sip_pvt_ptr = ao2_find(dialogs, &tmp_dialog, OBJ_POINTER, "ao2_find in dialogs");
+ sip_pvt_ptr = ao2_t_find(dialogs, &tmp_dialog, OBJ_POINTER, "ao2_find in dialogs");
if (sip_pvt_ptr) {
- rc = ao2_ref(sip_pvt_ptr,0,"");
+ rc = ao2_t_ref(sip_pvt_ptr,0,"");
ast_log(LOG_NOTICE,"Found CALL dialog %s, refcount = %d\n", tmp_dialog.callid, rc);
}
@@ -5661,9 +5661,9 @@
ast_log(LOG_NOTICE,"Dialog %s not found\n", callid);
i = ao2_iterator_init(dialogs, 0);
- while ((d2 = ao2_iterator_next(&i,"iterate thru dialogs "))) {
+ while ((d2 = ao2_t_iterator_next(&i,"iterate thru dialogs "))) {
ast_log(LOG_NOTICE, "Dialogs: %s\n", d2->callid);
- ao2_ref(d2,-1,"done with d2 pointer");
+ ao2_t_ref(d2,-1,"done with d2 pointer");
}
}
ast_string_field_free_memory(&tmp_dialog);
@@ -5674,7 +5674,7 @@
return sip_pvt_ptr;
}
} else { /* in pedantic mode! -- do the fancy linear search */
- p = ao2_callback(dialogs, 0 /* single, data */, find_call_cb, &arg, "pedantic linear search for dialog");
+ p = ao2_t_callback(dialogs, 0 /* single, data */, find_call_cb, &arg, "pedantic linear search for dialog");
if (p) {
sip_pvt_lock(p);
ast_mark(prof_find, 0);
@@ -9177,13 +9177,13 @@
if (peer->selfdestruct ||
ast_test_flag(&peer->flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
- int rc = ao2_ref(peer,0,"");
+ int rc = ao2_t_ref(peer,0,"");
ast_log(LOG_NOTICE,"Peer %s removing from the name hash. Refc=%d\n", peer->name, rc);
- ao2_unlink(peers, peer, "ao2_unlink of peer from peers table");
+ ao2_t_unlink(peers, peer, "ao2_unlink of peer from peers table");
- rc = ao2_ref(peer,0,"");
+ rc = ao2_t_ref(peer,0,"");
ast_log(LOG_NOTICE,"Peer %s removing from the IP hash. Refc=%d\n", peer->name, rc);
- ao2_unlink(peers_by_ip, peer, "ao2_unlink of peer from peers table");
+ ao2_t_unlink(peers_by_ip, peer, "ao2_unlink of peer from peers table");
}
return 0;
@@ -9945,7 +9945,7 @@
/* Create peer if we have autocreate mode enabled */
peer = temp_peer(name);
if (peer) {
- ao2_link(peers, peer,"link peer into peer table");
+ ao2_t_link(peers, peer,"link peer into peer table");
sip_cancel_destroy(p);
switch (parse_register_contact(p, peer, req)) {
case PARSE_REGISTER_FAILED:
@@ -10241,10 +10241,10 @@
if (!ast_string_field_init(&tmp_dialog, 100)) {
ast_string_field_set(&tmp_dialog, callid, callid);
- sip_pvt_ptr = ao2_find(dialogs, &tmp_dialog, OBJ_POINTER, "ao2_find of dialog in dialogs table");
+ sip_pvt_ptr = ao2_t_find(dialogs, &tmp_dialog, OBJ_POINTER, "ao2_find of dialog in dialogs table");
if (sip_pvt_ptr) {
char *ourtag = sip_pvt_ptr->tag;
- int rc = ao2_ref(sip_pvt_ptr,0,"");
+ int rc = ao2_t_ref(sip_pvt_ptr,0,"");
ast_log(LOG_NOTICE,"Found dialog %s refcount=%d\n", sip_pvt_ptr->callid, rc);
/* Go ahead and lock it (and its owner) before returning */
sip_pvt_lock(sip_pvt_ptr);
@@ -10885,7 +10885,7 @@
/* copy channel vars */
p->chanvars = copy_vars(peer->chanvars);
if (authpeer) {
- ao2_ref(peer,1,"copy pointer into (*authpeer)");
+ ao2_t_ref(peer,1,"copy pointer into (*authpeer)");
(*authpeer) = peer; /* Add a ref to the object here, to keep it in memory a bit longer if it is realtime */
}
@@ -11170,7 +11170,7 @@
i = ao2_iterator_init(users, 0);
- while ((user = ao2_iterator_next(&i,"iterate thru user table"))) {
+ while ((user = ao2_t_iterator_next(&i,"iterate thru user table"))) {
if (user->call_limit)
snprintf(ilimits, sizeof(ilimits), "%d", user->call_limit);
else
@@ -11185,7 +11185,7 @@
i = ao2_iterator_init(peers, 0);
- while ((peer = ao2_iterator_next(&i, "iterate thru peer table"))) {
+ while ((peer = ao2_t_iterator_next(&i, "iterate thru peer table"))) {
if (peer->call_limit)
snprintf(ilimits, sizeof(ilimits), "%d", peer->call_limit);
else
@@ -11301,7 +11301,7 @@
i = ao2_iterator_init(users, 0);
- while ((user = ao2_iterator_next(&i, "iterate thru user table"))) {
+ while ((user = ao2_t_iterator_next(&i, "iterate thru user table"))) {
if (havepattern && regexec(®exbuf, user->name, 0, NULL, 0)) {
ao2_unlock(user);
@@ -11475,7 +11475,7 @@
ast_cli(fd, FORMAT2, "Name/username", "Host", "Dyn", "Nat", "ACL", "Port", "Status", (realtimepeers ? "Realtime" : ""));
i = ao2_iterator_init(peers, 0);
- while ((peer = ao2_iterator_next(&i, "iterate thru peers table"))) {
+ while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) {
char status[20] = "";
char srch[2000];
char pstatus;
@@ -11572,7 +11572,7 @@
static int user_dump_func(void *userobj, void *arg, int flags)
{
struct sip_user *user = userobj;
- int refc = ao2_ref(userobj,0,"");
+ int refc = ao2_t_ref(userobj,0,"");
int *fd = arg;
char s[1000];
@@ -11585,7 +11585,7 @@
static int peer_dump_func(void *userobj, void *arg, int flags)
{
struct sip_peer *peer = userobj;
- int refc = ao2_ref(userobj,0,"");
+ int refc = ao2_t_ref(userobj,0,"");
int *fd = arg;
char s[1000];
@@ -11615,9 +11615,9 @@
if (a->argc != 3)
return CLI_SHOWUSAGE;
ast_cli(a->fd, "-= User objects: %d static, %d realtime =-\n\n", suserobjs, ruserobjs);
- ao2_callback(users, OBJ_NODATA, user_dump_func, &a->fd,"initiate ao2_callback to dump users");
+ ao2_t_callback(users, OBJ_NODATA, user_dump_func, &a->fd,"initiate ao2_callback to dump users");
ast_cli(a->fd, "-= Peer objects: %d static, %d realtime, %d autocreate =-\n\n", speerobjs, rpeerobjs, apeerobjs);
- ao2_callback(peers, OBJ_NODATA, peer_dump_func, &a->fd,"initiate ao2_callback to dump peers");
+ ao2_t_callback(peers, OBJ_NODATA, peer_dump_func, &a->fd,"initiate ao2_callback to dump peers");
ast_cli(a->fd, "-= Registry objects: %d =-\n\n", regobjs);
ASTOBJ_CONTAINER_DUMP(a->fd, tmp, sizeof(tmp), ®l);
return CLI_SUCCESS;
@@ -11824,7 +11824,7 @@
ao2_lock(peers); /* was WRLOCK */
i = ao2_iterator_init(peers, 0);
- while ((pi = ao2_iterator_next(&i,"iterate thru peers table"))) {
+ while ((pi = ao2_t_iterator_next(&i,"iterate thru peers table"))) {
if (name && regexec(®exbuf, pi->name, 0, NULL, 0)) {
unref_peer(pi,"toss iterator peer ptr before continue");
continue;
@@ -11837,7 +11837,7 @@
}
if (pruned) {
ast_log(LOG_NOTICE,"Callback to PRUNE PEERS\n");
- ao2_callback(peers, OBJ_NODATA|OBJ_UNLINK, peer_is_marked, 0, "initiating callback to remove marked peers");
+ ao2_t_callback(peers, OBJ_NODATA|OBJ_UNLINK, peer_is_marked, 0, "initiating callback to remove marked peers");
ast_cli(a->fd, "%d peers pruned.\n", pruned);
} else
ast_cli(a->fd, "No peers found to prune.\n");
@@ -11848,7 +11848,7 @@
ao2_lock(users); /* was WRLOCK */
i = ao2_iterator_init(users, 0);
- while ((ui = ao2_iterator_next(&i, "iterate thru users table"))) {
+ while ((ui = ao2_t_iterator_next(&i, "iterate thru users table"))) {
if (name && regexec(®exbuf, ui->name, 0, NULL, 0)) {
unref_user(ui,"toss iterator user ptr before continue");
continue;
@@ -11861,7 +11861,7 @@
}
if (pruned) {
ast_log(LOG_NOTICE,"Callback to PRUNE USERS\n");
- ao2_callback(users, OBJ_NODATA|OBJ_UNLINK, user_is_marked, 0, "callback to remove marked users");
+ ao2_t_callback(users, OBJ_NODATA|OBJ_UNLINK, user_is_marked, 0, "callback to remove marked users");
ast_cli(a->fd, "%d users pruned.\n", pruned);
} else
ast_cli(a->fd, "No users found to prune.\n");
@@ -11871,13 +11871,13 @@
if (prunepeer) {
struct sip_peer tmp;
ast_copy_string(tmp.name, name, sizeof(tmp.name));
- if ((peer = ao2_find(peers, &tmp, OBJ_POINTER|OBJ_UNLINK, "finding to unlink from peers"))) {
- ao2_unlink(peers_by_ip,peer,"unlinking peer from peers_by_ip also");
+ if ((peer = ao2_t_find(peers, &tmp, OBJ_POINTER|OBJ_UNLINK, "finding to unlink from peers"))) {
+ ao2_t_unlink(peers_by_ip,peer,"unlinking peer from peers_by_ip also");
if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
ast_cli(a->fd, "Peer '%s' is not a Realtime peer, cannot be pruned.\n", name);
/* put it back! */
- ao2_link(peers, peer, "link peer into peer table");
- ao2_link(peers_by_ip, peer, "link peer into peers_by_ip table");
+ ao2_t_link(peers, peer, "link peer into peer table");
+ ao2_t_link(peers_by_ip, peer, "link peer into peers_by_ip table");
} else
ast_cli(a->fd, "Peer '%s' pruned.\n", name);
unref_peer(peer,"sip_prune_realtime: unref_peer: tossing temp peer ptr");
@@ -11887,11 +11887,11 @@
if (pruneuser) {
struct sip_user tmp;
ast_copy_string(tmp.name, name, sizeof(tmp.name));
- if ((user = ao2_find(users, &tmp, OBJ_POINTER|OBJ_UNLINK, "finding to unlink from users table"))) {
+ if ((user = ao2_t_find(users, &tmp, OBJ_POINTER|OBJ_UNLINK, "finding to unlink from users table"))) {
if (!ast_test_flag(&user->flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
ast_cli(a->fd, "User '%s' is not a Realtime user, cannot be pruned.\n", name);
/* put it back! */
- ao2_link(users, user, "link unlinked user back into users table");
+ ao2_t_link(users, user, "link unlinked user back into users table");
} else
ast_cli(a->fd, "User '%s' pruned.\n", name);
unref_user(user,"unref_user: Tossing temp user ptr");
@@ -12692,7 +12692,7 @@
ast_cli(arg.fd, FORMAT3, "Peer", "User", "Call ID", "Extension", "Last state", "Type", "Mailbox");
/* iterate on the container and invoke the callback on each item */
- ao2_callback(dialogs, OBJ_NODATA, show_channels_cb, &arg,"callback to show channels");
+ ao2_t_callback(dialogs, OBJ_NODATA, show_channels_cb, &arg,"callback to show channels");
/* print summary information */
ast_cli(arg.fd, "%d active SIP %s%s\n", arg.numchans,
@@ -12721,13 +12721,13 @@
i = ao2_iterator_init(dialogs, 0);
- while ((cur = ao2_iterator_next(&i, "iterate thru dialogs"))) {
+ while ((cur = ao2_t_iterator_next(&i, "iterate thru dialogs"))) {
if (!strncasecmp(word, cur->callid, wordlen) && ++which > state) {
c = ast_strdup(cur->callid);
- ao2_ref(cur,-1,"drop ref in iterator loop break");
+ ao2_t_ref(cur,-1,"drop ref in iterator loop break");
break;
}
- ao2_ref(cur,-1, "drop ref in iterator loop");
+ ao2_t_ref(cur,-1, "drop ref in iterator loop");
}
return c;
}
@@ -12742,7 +12742,7 @@
struct ao2_iterator i = ao2_iterator_init(peers,0);
struct sip_peer *peer;
- while ((peer = ao2_iterator_next(&i, "iterate thru peers table"))) {
+ while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) {
/* locking of the object is not required because only the name and flags are being compared */
if (!strncasecmp(word, peer->name, wordlen) &&
(!flags2 || ast_test_flag(&peer->flags[1], flags2)) &&
@@ -12767,7 +12767,7 @@
struct sip_peer *peer;
i = ao2_iterator_init(peers, 0);
- while ((peer = ao2_iterator_next(&i, "iterate thru peers table"))) {
+ while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) {
if (!strncasecmp(word, peer->name, wordlen) &&
(!flags2 || ast_test_flag(&peer->flags[1], flags2)) &&
++which > state && peer->expire > 0)
@@ -12819,7 +12819,7 @@
i = ao2_iterator_init(users, 0);
- while ((user = ao2_iterator_next(&i, "iterate thru users table"))) {
+ while ((user = ao2_t_iterator_next(&i, "iterate thru users table"))) {
/* locking of the object is not required because only the name and flags are being compared */
if (!strncasecmp(word, user->name, wordlen)) {
if (flags2 && !ast_test_flag(&user->flags[1], flags2)) {
@@ -12904,7 +12904,7 @@
i = ao2_iterator_init(dialogs, 0);
- while ((cur = ao2_iterator_next(&i, "iterate thru dialogs"))) {
+ while ((cur = ao2_t_iterator_next(&i, "iterate thru dialogs"))) {
if (!strncasecmp(cur->callid, a->argv[3], len)) {
char formatbuf[BUFSIZ/2];
ast_cli(a->fd,"\n");
@@ -12956,7 +12956,7 @@
ast_cli(a->fd, "\n\n");
found++;
}
- ao2_ref(cur,-1,"toss dialog ptr set by iterator_next");
+ ao2_t_ref(cur,-1,"toss dialog ptr set by iterator_next");
}
dialoglist_unlock();
if (!found)
@@ -12990,7 +12990,7 @@
len = strlen(a->argv[3]);
dialoglist_lock();
i = ao2_iterator_init(dialogs, 0);
- while ((cur = ao2_iterator_next(&i,"iterate thru dialogs"))) {
+ while ((cur = ao2_t_iterator_next(&i,"iterate thru dialogs"))) {
if (!strncasecmp(cur->callid, a->argv[3], len)) {
struct sip_history *hist;
int x = 0;
@@ -13007,7 +13007,7 @@
ast_cli(a->fd, "Call '%s' has no history\n", cur->callid);
found++;
}
- ao2_ref(cur,-1,"toss dialog ptr from iterator_next");
+ ao2_t_ref(cur,-1,"toss dialog ptr from iterator_next");
}
dialoglist_unlock();
if (!found)
@@ -13389,9 +13389,9 @@
ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
build_via(p);
ast_log(LOG_NOTICE,"====================================About to build callid for %s\n", p->callid);
- ao2_unlink(dialogs,p,"About to change the callid -- remove the old name");
+ ao2_t_unlink(dialogs,p,"About to change the callid -- remove the old name");
build_callid_pvt(p);
- ao2_link(dialogs,p,"Linking in new name");
+ ao2_t_link(dialogs,p,"Linking in new name");
ast_log(LOG_NOTICE,"====================================New callid: %s\n", p->callid);
ast_cli(a->fd, "Sending NOTIFY of type '%s' to '%s'\n", a->argv[2], a->argv[i]);
dialog_ref(p,"bump the count of p, which transmit_sip_request will decrement.");
@@ -16157,7 +16157,7 @@
sip_pvt_unlock(targetcall_pvt);
ast_channel_unlock(current->chan1);
if (targetcall_pvt)
- ao2_ref(targetcall_pvt,-1,"Drop targetcall_pvt pointer");
+ ao2_t_ref(targetcall_pvt,-1,"Drop targetcall_pvt pointer");
return -1;
}
@@ -16219,7 +16219,7 @@
}
}
if (targetcall_pvt)
- ao2_ref(targetcall_pvt,-1,"drop targetcall_pvt");
+ ao2_t_ref(targetcall_pvt,-1,"drop targetcall_pvt");
return 1;
}
@@ -17069,17 +17069,17 @@
i = ao2_iterator_init(dialogs, 0);
- while ((p_old = ao2_iterator_next(&i,"iterate thru dialogs"))) {
+ while ((p_old = ao2_t_iterator_next(&i,"iterate thru dialogs"))) {
if (p_old == p) {
- ao2_ref(p_old,-1,"toss dialog ptr from iterator_next before continue");
+ ao2_t_ref(p_old,-1,"toss dialog ptr from iterator_next before continue");
continue;
}
if (p_old->initreq.method != SIP_SUBSCRIBE) {
- ao2_ref(p_old,-1,"toss dialog ptr from iterator_next before continue");
+ ao2_t_ref(p_old,-1,"toss dialog ptr from iterator_next before continue");
continue;
}
if (p_old->subscribed == NONE) {
- ao2_ref(p_old,-1,"toss dialog ptr from iterator_next before continue");
+ ao2_t_ref(p_old,-1,"toss dialog ptr from iterator_next before continue");
continue;
}
sip_pvt_lock(p_old);
@@ -17088,12 +17088,12 @@
!strcmp(p_old->context, p->context)) {
p_old->needdestroy = 1;
sip_pvt_unlock(p_old);
- ao2_ref(p_old,-1,"toss dialog ptr from iterator_next before break");
+ ao2_t_ref(p_old,-1,"toss dialog ptr from iterator_next before break");
break;
}
}
sip_pvt_unlock(p_old);
- ao2_ref(p_old,-1,"toss dialog ptr from iterator_next");
+ ao2_t_ref(p_old,-1,"toss dialog ptr from iterator_next");
}
dialoglist_unlock();
}
@@ -17437,7 +17437,7 @@
ast_debug(1, "Failed to grab owner channel lock, trying again. (SIP call %s)\n", p->callid);
sip_pvt_unlock(p);
if (lockretry != 1)
- ao2_ref(p,-1,"release p inside lockretry loop"); /* we'll look for it again, but p is dead now */
+ ao2_t_ref(p,-1,"release p inside lockretry loop"); /* we'll look for it again, but p is dead now */
ast_mutex_unlock(&netlock);
/* Sleep for a very short amount of time */
usleep(1);
@@ -17455,7 +17455,7 @@
transmit_response(p, "503 Server error", &req); /* We must respond according to RFC 3261 sec 12.2 */
/* XXX We could add retry-after to make sure they come back */
append_history(p, "LockFail", "Owner lock failed, transaction failed.");
- ao2_ref(p, -1, "release p at end of lockretry"); /* p is gone after the return */
+ ao2_t_ref(p, -1, "release p at end of lockretry"); /* p is gone after the return */
return 1;
}
nounlock = 0;
@@ -17470,7 +17470,7 @@
ast_mutex_unlock(&netlock);
if (recount)
ast_update_use_count();
- ao2_ref(p, -1, "throw away dialog ptr at end of routine"); /* p is gone after the return */
+ ao2_t_ref(p, -1, "throw away dialog ptr at end of routine"); /* p is gone after the return */
return 1;
}
@@ -17547,9 +17547,9 @@
ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
ast_log(LOG_NOTICE,"====================================About to build callid for %s\n", p->callid);
build_via(p);
- ao2_unlink(dialogs,p,"About to change the callid -- remove the old name");
+ ao2_t_unlink(dialogs,p,"About to change the callid -- remove the old name");
build_callid_pvt(p);
- ao2_link(dialogs,p,"Linking in under new name");
+ ao2_t_link(dialogs,p,"Linking in under new name");
ast_log(LOG_NOTICE,"====================================New callid: %s\n", p->callid);
/* Destroy this session after 32 secs */
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
@@ -17672,7 +17672,7 @@
get back to this point every millisecond or less)
*/
- ao2_callback(dialogs, OBJ_UNLINK|OBJ_NODATA, dialog_needdestroy, &t, "callback to remove dialogs w/needdestroy");
+ ao2_t_callback(dialogs, OBJ_UNLINK|OBJ_NODATA, dialog_needdestroy, &t, "callback to remove dialogs w/needdestroy");
pthread_testcancel();
/* Wait for sched or io */
@@ -17802,9 +17802,9 @@
ast_log(LOG_NOTICE,"====================================About to build callid for %s\n", p->callid);
ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
build_via(p);
- ao2_unlink(dialogs,p,"About to change the callid -- remove the old name");
+ ao2_t_unlink(dialogs,p,"About to change the callid -- remove the old name");
build_callid_pvt(p);
- ao2_link(dialogs,p,"Linking in under new name");
+ ao2_t_link(dialogs,p,"Linking in under new name");
ast_log(LOG_NOTICE,"====================================New callid: %s\n", p->callid);
if (peer->pokeexpire > -1) {
@@ -18029,9 +18029,9 @@
ast_log(LOG_NOTICE,"====================================About to build callid for %s\n", p->callid);
ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
build_via(p);
- ao2_unlink(dialogs,p,"About to change the callid -- remove the old name");
+ ao2_t_unlink(dialogs,p,"About to change the callid -- remove the old name");
build_callid_pvt(p);
- ao2_link(dialogs,p,"Linking in under new name");
+ ao2_t_link(dialogs,p,"Linking in under new name");
ast_log(LOG_NOTICE,"====================================New callid: %s\n", p->callid);
/* We have an extension to call, don't use the full contact here */
@@ -18388,7 +18388,7 @@
ast_log(LOG_NOTICE,"Allocating USER object for %s\n", name);
- if (!(user = ao2_alloc(sizeof(*user), sip_destroy_user_fn, "allocate a user struct")))
+ if (!(user = ao2_t_alloc(sizeof(*user), sip_destroy_user_fn, "allocate a user struct")))
return NULL;
suserobjs++;
@@ -18544,7 +18544,7 @@
struct sip_peer *peer;
ast_log(LOG_NOTICE,"Allocating PEER object for the %s\n", name);
- if (!(peer = ao2_alloc(sizeof(*peer), sip_destroy_peer_fn, "allocate a peer struct")))
+ if (!(peer = ao2_t_alloc(sizeof(*peer), sip_destroy_peer_fn, "allocate a peer struct")))
return NULL;
apeerobjs++;
@@ -18607,7 +18607,7 @@
strcpy(tmp_peer.name, name);
/* peer = ASTOBJ_CONTAINER_FIND_UNLINK_FULL(&peerl, name, name, 0, 0, strcmp); */
ast_log(LOG_NOTICE,"UNLINK peer %s\n", name);
- peer = ao2_find(peers, &tmp_peer, OBJ_POINTER|OBJ_UNLINK,"find and unlink peer from peers table");
+ peer = ao2_t_find(peers, &tmp_peer, OBJ_POINTER|OBJ_UNLINK,"find and unlink peer from peers table");
}
if (peer) {
@@ -18618,7 +18618,7 @@
} else {
ast_log(LOG_NOTICE,"Allocating PEER object to %s\n", name);
- if (!(peer = ao2_alloc(sizeof(*peer),sip_destroy_peer_fn, "allocate a peer struct")))
+ if (!(peer = ao2_t_alloc(sizeof(*peer),sip_destroy_peer_fn, "allocate a peer struct")))
return NULL;
if (realtime) {
@@ -18961,13 +18961,13 @@
} while(0));
/* Then, actually destroy users and registry */
- ao2_ref(users, -1,"destroy users table");
+ ao2_t_ref(users, -1,"destroy users table");
ast_debug(4, "--------------- Done destroying user list\n");
ASTOBJ_CONTAINER_DESTROYALL(®l, sip_registry_destroy);
ast_debug(4, "--------------- Done destroying registry list\n");
- ao2_callback(peers, OBJ_NODATA, peer_markall_func, 0, "callback to mark all peers");
+ ao2_t_callback(peers, OBJ_NODATA, peer_markall_func, 0, "callback to mark all peers");
/* reinstate the user table */
- users = ao2_container_alloc(hash_user_size, user_hash_cb, user_cmp_cb,"allocate users");
+ users = ao2_t_container_alloc(hash_user_size, user_hash_cb, user_cmp_cb,"allocate users");
}
ast_log(LOG_NOTICE,"reload_config 3...\n");
@@ -19401,8 +19401,8 @@
peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
if (peer) {
ast_device_state_changed("SIP/%s", peer->name);
- ao2_link(peers, peer, "link peer into peer table");
- ao2_link(peers_by_ip, peer, "link peer into peers_by_ip table");
+ ao2_t_link(peers, peer, "link peer into peer table");
+ ao2_t_link(peers_by_ip, peer, "link peer into peers_by_ip table");
unref_peer(peer,"unref_peer: from reload_config");
peer_count++;
}
@@ -19463,7 +19463,7 @@
if (is_user) {
user = build_user(cat, ast_variable_browse(cfg, cat), 0);
if (user) {
- ao2_link(users, user, "link user into users table");
+ ao2_t_link(users, user, "link user into users table");
unref_user(user,"unref_user from reload_config, near end");
user_count++;
}
@@ -19471,8 +19471,8 @@
if (is_peer) {
peer = build_peer(cat, ast_variable_browse(cfg, cat), NULL, 0);
if (peer) {
- ao2_link(peers, peer,"link peer into peers table");
- ao2_link(peers_by_ip, peer,"link peer into peers_by_ip table");
+ ao2_t_link(peers, peer,"link peer into peers table");
+ ao2_t_link(peers_by_ip, peer,"link peer into peers_by_ip table");
unref_peer(peer,"unref_peer: reload_config: just linked peer to two tables, peers and peers_by_ip");
peer_count++;
}
@@ -20044,7 +20044,7 @@
if (!speerobjs) /* No peers, just give up */
return;
- while ((peer = ao2_iterator_next(&i, "iterate thru peers table"))) {
+ while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) {
ms += 100;
ast_log(LOG_WARNING,"About to sched_replace peer pokeexpire(%d) for peer in sip_poke_all_peers\n", peer->pokeexpire);
peer->pokeexpire = ast_sched_replace(peer->pokeexpire,
@@ -20082,7 +20082,7 @@
/* Prune peers who still are supposed to be deleted */
ast_log(LOG_NOTICE,"Callback to prune marked peers\n");
- ao2_callback(peers, OBJ_NODATA|OBJ_UNLINK, peer_is_marked, 0, "callback to remove marked peers");
+ ao2_t_callback(peers, OBJ_NODATA|OBJ_UNLINK, peer_is_marked, 0, "callback to remove marked peers");
ast_debug(4, "--------------- Done destroying pruned peers\n");
@@ -20162,10 +20162,10 @@
ast_verbose("SIP channel loading...\n");
/* the fact that ao2_containers can't resize automatically is a major worry! */
/* if the number of objects gets above MAX_XXX_BUCKETS, things will slow down */
- users = ao2_container_alloc(hash_user_size, user_hash_cb, user_cmp_cb,"allocate users");
- peers = ao2_container_alloc(hash_peer_size, peer_hash_cb, peer_cmp_cb,"allocate peers");
- peers_by_ip = ao2_container_alloc(hash_peer_size, peer_iphash_cb, peer_ipcmp_cb,"allocate peers_by_ip");
- dialogs = ao2_container_alloc(hash_dialog_size, dialog_hash_cb, dialog_cmp_cb,"allocate dialogs");
+ users = ao2_t_container_alloc(hash_user_size, user_hash_cb, user_cmp_cb,"allocate users");
+ peers = ao2_t_container_alloc(hash_peer_size, peer_hash_cb, peer_cmp_cb,"allocate peers");
+ peers_by_ip = ao2_t_container_alloc(hash_peer_size, peer_iphash_cb, peer_ipcmp_cb,"allocate peers_by_ip");
+ dialogs = ao2_t_container_alloc(hash_dialog_size, dialog_hash_cb, dialog_cmp_cb,"allocate dialogs");
ASTOBJ_CONTAINER_INIT(®l); /* Registry object list -- not searched for anything */
@@ -20280,10 +20280,10 @@
dialoglist_lock();
/* Hangup all dialogs if they have an owner */
i = ao2_iterator_init(dialogs, 0);
- while ((p = ao2_iterator_next(&i, "iterate thru dialogs"))) {
+ while ((p = ao2_t_iterator_next(&i, "iterate thru dialogs"))) {
if (p->owner)
ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
- ao2_ref(p,-1,"toss dialog ptr from iterator_next");
+ ao2_t_ref(p,-1,"toss dialog ptr from iterator_next");
}
dialoglist_unlock();
@@ -20301,9 +20301,9 @@
dialoglist_lock();
/* Destroy all the dialogs and free their memory */
i = ao2_iterator_init(dialogs, 0);
- while ((p = ao2_iterator_next(&i, "iterate thru dialogs"))) {
- ao2_unlink(dialogs,p,"unlink from dialogs");
- ao2_ref(p,-1,"throw away iterator result");
+ while ((p = ao2_t_iterator_next(&i, "iterate thru dialogs"))) {
+ ao2_t_unlink(dialogs,p,"unlink from dialogs");
+ ao2_t_ref(p,-1,"throw away iterator result");
}
dialoglist_unlock();
@@ -20318,10 +20318,10 @@
ASTOBJ_CONTAINER_DESTROY(®l);
ast_log(LOG_NOTICE,"Unload 12\n");
- ao2_ref(peers, -1, "unref the peers table");
- ao2_ref(peers_by_ip, -1, "unref the peers_by_ip table");
- ao2_ref(users, -1, "unref the users table");
- ao2_ref(dialogs, -1, "unref the dialogs table");
+ ao2_t_ref(peers, -1, "unref the peers table");
+ ao2_t_ref(peers_by_ip, -1, "unref the peers_by_ip table");
+ ao2_t_ref(users, -1, "unref the users table");
+ ao2_t_ref(dialogs, -1, "unref the dialogs table");
ast_log(LOG_NOTICE,"Unload 13\n");
clear_sip_domains();
Modified: team/murf/bug11210/funcs/func_dialgroup.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/funcs/func_dialgroup.c?view=diff&rev=94815&r1=94814&r2=94815
==============================================================================
--- team/murf/bug11210/funcs/func_dialgroup.c (original)
+++ team/murf/bug11210/funcs/func_dialgroup.c Wed Dec 26 16:16:03 2007
@@ -37,26 +37,6 @@
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/astobj2.h"
-#define ao2_ref(arg1, arg2) ao2_ref_debug((arg1), (arg2), "func_dialgroup", __FILE__, __LINE__, __PRETTY_FUNCTION__)
[... 560 lines stripped ...]
More information about the asterisk-commits
mailing list