[asterisk-commits] russell: branch russell/iax2_poke_fix r87627 - /team/russell/iax2_poke_fix/ch...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Oct 30 13:31:18 CDT 2007
Author: russell
Date: Tue Oct 30 13:31:18 2007
New Revision: 87627
URL: http://svn.digium.com/view/asterisk?view=rev&rev=87627
Log:
Change the way expire_registry() gets used. Every usage passed peer->name,
and then expire_registry() would do a lookup in peers based on that name. That
is a whole lot of unnecessary work when the peer itself could just be passed in
the first place.
Modified:
team/russell/iax2_poke_fix/channels/chan_iax2.c
Modified: team/russell/iax2_poke_fix/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/russell/iax2_poke_fix/channels/chan_iax2.c?view=diff&rev=87627&r1=87626&r2=87627
==============================================================================
--- team/russell/iax2_poke_fix/channels/chan_iax2.c (original)
+++ team/russell/iax2_poke_fix/channels/chan_iax2.c Tue Oct 30 13:31:18 2007
@@ -2145,7 +2145,7 @@
} else if ((peer = find_peer(argv[3], 0))) {
if(ast_test_flag(peer, IAX_RTCACHEFRIENDS)) {
ast_set_flag(peer, IAX_RTAUTOCLEAR);
- expire_registry((const void *)peer->name);
+ expire_registry(peer);
ast_cli(fd, "OK peer %s was removed from the cache.\n", argv[3]);
} else {
ast_cli(fd, "SORRY peer %s is not eligible for this operation.\n", argv[3]);
@@ -2741,7 +2741,7 @@
if (ast_test_flag(peer, IAX_RTAUTOCLEAR)) {
if (peer->expire > -1)
ast_sched_del(sched, peer->expire);
- peer->expire = iax2_sched_add(sched, (global_rtautoclear) * 1000, expire_registry, (void*)peer->name);
+ peer->expire = iax2_sched_add(sched, (global_rtautoclear) * 1000, expire_registry, peer);
}
ao2_link(peers, peer_ref(peer));
if (ast_test_flag(peer, IAX_DYNAMIC))
@@ -5773,13 +5773,8 @@
static void __expire_registry(const void *data)
{
- const char *name = data;
- struct iax2_peer *peer = NULL;
- struct iax2_peer tmp_peer = {
- .name = name,
- };
-
- peer = ao2_find(peers, &tmp_peer, OBJ_POINTER);
+ struct iax2_peer *peer = (struct iax2_peer *) data;
+
if (!peer)
return;
@@ -5802,8 +5797,6 @@
if (ast_test_flag(peer, IAX_RTAUTOCLEAR))
ao2_unlink(peers, peer);
-
- peer_unref(peer);
}
static int expire_registry(const void *data)
@@ -5844,7 +5837,7 @@
if (p->expire > -1)
ast_sched_del(sched, p->expire);
ast_device_state_changed("IAX2/%s", p->name); /* Activate notification */
- p->expire = iax2_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, (void *)p->name);
+ p->expire = iax2_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, p);
if (iax2_regfunk)
iax2_regfunk(p->name, 1);
register_peer_exten(p, 1);
@@ -5950,7 +5943,7 @@
p->expiry = refresh;
}
if (p->expiry && sin->sin_addr.s_addr)
- p->expire = iax2_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, (const void *)p->name);
+ p->expire = iax2_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, p);
iax_ie_append_str(&ied, IAX_IE_USERNAME, p->name);
iax_ie_append_int(&ied, IAX_IE_DATETIME, iax2_datetime(p->zonetag));
if (sin->sin_addr.s_addr) {
More information about the asterisk-commits
mailing list