[asterisk-commits] murf: branch murf/bug11210 r98977 - /team/murf/bug11210/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jan 16 15:29:51 CST 2008
Author: murf
Date: Wed Jan 16 15:29:51 2008
New Revision: 98977
URL: http://svn.digium.com/view/asterisk?view=rev&rev=98977
Log:
OK, found out why were freezing on the attempt to lock registry entries-- they were stale pointers to freed objects. Oh, the shame of it. Fixed that and turned up a problem on unload of infinite loops on sched_del calls. Got that cleaned up. What else could possibly go wrong... don't say anything.
Modified:
team/murf/bug11210/channels/chan_sip.c
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=98977&r1=98976&r2=98977
==============================================================================
--- team/murf/bug11210/channels/chan_sip.c (original)
+++ team/murf/bug11210/channels/chan_sip.c Wed Jan 16 15:29:51 2008
@@ -3226,8 +3226,17 @@
peer->chanvars = NULL;
}
if (peer->expire > -1) {
- ast_sched_del(sched, peer->expire); /* HUH? normally, if peer were being refcounted thru sched calls, we'd
+ int ret = ast_sched_del(sched, peer->expire); /* HUH? normally, if peer were being refcounted thru sched calls, we'd
+ add code after this to unref the peer */
+ if (ret == 0) /* if it succeeds, we can wipe out the entry */
+ peer->expire = -1;
+
+ }
+ if (peer->pokeexpire > -1) {
+ int ret = ast_sched_del(sched, peer->pokeexpire); /* HUH? normally, if peer were being refcounted thru sched calls, we'd
add code after this to unref the peer */
+ if (ret == 0) /* if it succeeds, we can wipe out the entry */
+ peer->expire = -1;
}
/* If the schedule delete fails, that means the schedule is currently
@@ -3236,6 +3245,7 @@
*
* NOTE: once peer is refcounted, this probably is no longer necessary.
*/
+
while (peer->expire > -1 && ast_sched_del(sched, peer->expire))
usleep(1);
while (peer->pokeexpire > -1 && ast_sched_del(sched, peer->pokeexpire))
@@ -9162,13 +9172,13 @@
if (!peer) /* Hmmm. We have no peer. Weird. */
return 0;
+ peer->expire = -1;
memset(&peer->addr, 0, sizeof(peer->addr));
destroy_association(peer); /* remove registration data from storage */
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", peer->name);
register_peer_exten(peer, FALSE); /* Remove regexten */
- peer->expire = -1;
ast_device_state_changed("SIP/%s", peer->name);
/* Do we need to release this peer from memory?
@@ -14606,7 +14616,9 @@
/* Schedule re-registration before we expire */
r->expire = ast_sched_replace(r->expire, sched, expires_ms, sip_reregister, r);
- registry_unref(r,"unref registry ptr r"); /* HUH? if this gets deleted, p->registry will be a bad pointer! */
+ /* it is clear that we would not want to destroy the registry entry if we just
+ scheduled a callback and recorded it in there! */
+ /* since we never bumped the count, we shouldn't decrement it! registry_unref(r,"unref registry ptr r");*/ /* HUH? if this gets deleted, p->registry will be a bad pointer! */
/* shouldn't this be:
p->registry = registry_unref(r,"unref registry entry at p->registry");
???????
@@ -20912,7 +20924,8 @@
ast_manager_unregister("SIPpeers");
ast_manager_unregister("SIPshowpeer");
ast_manager_unregister("SIPshowregistry");
-
+ ast_log(LOG_NOTICE,"About to hangup dialogs\n");
+
dialoglist_lock();
/* Hangup all dialogs if they have an owner */
i = ao2_iterator_init(dialogs, 0);
@@ -20922,6 +20935,7 @@
ao2_t_ref(p,-1,"toss dialog ptr from iterator_next");
}
dialoglist_unlock();
+ ast_log(LOG_NOTICE,"...Done! Now, grab a monitor lock and join threads...\n");
ast_mutex_lock(&monlock);
if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) {
@@ -20931,6 +20945,7 @@
}
monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
+ ast_log(LOG_NOTICE,"...Done! Now, grab the dialoglist lock and get rid of the dialogs...\n");
dialoglist_lock();
/* Destroy all the dialogs and free their memory */
@@ -20941,25 +20956,38 @@
}
dialoglist_unlock();
+ ast_log(LOG_NOTICE,"...Done! Now, free up the ha's...\n");
/* Free memory for local network address mask */
ast_free_ha(localaddr);
+ ast_log(LOG_NOTICE,"...Done! Now, free up the realm_authentication...\n");
clear_realm_authentication(authl);
+ ast_log(LOG_NOTICE,"...Done! Now, free up the registry entries...\n");
ASTOBJ_CONTAINER_DESTROYALL(®l, sip_registry_destroy);
+ ast_log(LOG_NOTICE,"...Done! Now, free up the registry List...\n");
ASTOBJ_CONTAINER_DESTROY(®l);
+ ast_log(LOG_NOTICE,"...Done! Now, free up the peers...\n");
ao2_t_ref(peers, -1, "unref the peers table");
+ ast_log(LOG_NOTICE,"...Done! Now, free up the peers-by-ip...\n");
ao2_t_ref(peers_by_ip, -1, "unref the peers_by_ip table");
+ ast_log(LOG_NOTICE,"...Done! Now, free up the users...\n");
ao2_t_ref(users, -1, "unref the users table");
+ ast_log(LOG_NOTICE,"...Done! Now, free up the dialogs table itself...\n");
ao2_t_ref(dialogs, -1, "unref the dialogs table");
+ ast_log(LOG_NOTICE,"...Done! Now, clear up the sip domains info...\n");
clear_sip_domains();
+ ast_log(LOG_NOTICE,"...Done! Now, close the sip socket...\n");
close(sipsock);
+ ast_log(LOG_NOTICE,"...Done! Now, destroy the scheduler's context...\n");
sched_context_destroy(sched);
+ ast_log(LOG_NOTICE,"...Done! Now, destroy the scheduler's used context...\n");
con = ast_context_find(used_context);
if (con)
ast_context_destroy(con, "SIP");
+ ast_log(LOG_NOTICE,"...Done!\n");
return 0;
}
More information about the asterisk-commits
mailing list