aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-29 00:06:35 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-29 00:06:35 +0000
commit7a29f51638773375101d27d3b101180c75557b92 (patch)
treea482a3d7d208c65bbc68fd52ddefcf327c9333f7 /channels
parent3507ec0ea09c8f257a730fb5bb33816de731808d (diff)
make register_unref() return NULL so it is easy to cleanup
the original pointer while calling the function. on passing add some comments on one of the places where it is used, and explain why it is safe there. again, a no-op for practical purposes. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@77654 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 444c319e9..2906a4c1e 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1878,10 +1878,11 @@ static void unref_user(struct sip_user *user)
ASTOBJ_UNREF(user, sip_destroy_user);
}
-static void registry_unref(struct sip_registry *reg)
+static void *registry_unref(struct sip_registry *reg)
{
ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount - 1);
ASTOBJ_UNREF(reg, sip_registry_destroy);
+ return NULL;
}
/*! \brief Add object reference to SIP registry */
@@ -3531,7 +3532,7 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
if (p->registry) {
if (p->registry->call == p)
p->registry->call = NULL;
- registry_unref(p->registry);
+ p->registry = registry_unref(p->registry);
}
/* Unlink us from the owner if we have one */
@@ -7994,17 +7995,18 @@ static int sip_reg_timeout(void *data)
/* Unlink us, destroy old call. Locking is not relevant here because all this happens
in the single SIP manager thread. */
p = r->call;
- if (p->registry) {
- registry_unref(p->registry);
- p->registry = NULL;
- }
- r->call = NULL;
p->needdestroy = 1;
/* Pretend to ACK anything just in case */
__sip_pretend_ack(p); /* XXX we need p locked, not sure we have */
+
+ /* decouple the two objects */
+ /* p->registry == r, so r has 2 refs, and the unref won't take the object away */
+ if (p->registry)
+ p->registry = registry_unref(p->registry);
+ r->call = dialog_unref(r->call);
}
/* If we have a limit, stop registration and give up */
- if (global_regattempts_max && (r->regattempts > global_regattempts_max)) {
+ if (global_regattempts_max && r->regattempts > global_regattempts_max) {
/* Ok, enough is enough. Don't try any more */
/* We could add an external notification here...
steal it from app_voicemail :-) */