diff options
author | Joshua Colp <jcolp@digium.com> | 2008-10-14 15:00:41 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2008-10-14 15:00:41 +0000 |
commit | f230048cd39bfa0770fd05823df118cfb9cfb363 (patch) | |
tree | f42839df01c98191df49039f42c72230a370c89c /channels/chan_sip.c | |
parent | 5d2a169fb1460cb692b27179c5aed308621a85de (diff) |
Fix reference count issue that Russell brought up in SIP MWI NOTIFY support. Bump the reference count up before we add it to the scheduler, duh.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@148867 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index e383f88e2..19e1fafa0 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -9376,7 +9376,7 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init) /*! \brief Send a subscription or resubscription for MWI */ static int sip_subscribe_mwi_do(const void *data) { - struct sip_subscription_mwi *mwi = ASTOBJ_REF((struct sip_subscription_mwi *) data); + struct sip_subscription_mwi *mwi = (struct sip_subscription_mwi*)data; if (!mwi) { return -1; @@ -15905,7 +15905,9 @@ static void handle_response_subscribe(struct sip_pvt *p, int resp, char *rest, s p->options = NULL; } p->mwi->subscribed = 1; - p->mwi->resub = ast_sched_add(sched, mwi_expiry * 1000, sip_subscribe_mwi_do, p->mwi); + if ((p->mwi->resub = ast_sched_add(sched, mwi_expiry * 1000, sip_subscribe_mwi_do, ASTOBJ_REF(p->mwi))) < 0) { + ASTOBJ_UNREF(p->mwi, sip_subscribe_mwi_destroy); + } break; case 401: case 407: @@ -23063,7 +23065,9 @@ static void sip_send_all_mwi_subscriptions(void) ASTOBJ_CONTAINER_TRAVERSE(&submwil, 1, do { ASTOBJ_WRLOCK(iterator); AST_SCHED_DEL(sched, iterator->resub); - iterator->resub = ast_sched_add(sched, 1, sip_subscribe_mwi_do, iterator); + if ((iterator->resub = ast_sched_add(sched, 1, sip_subscribe_mwi_do, ASTOBJ_REF(iterator))) < 0) { + ASTOBJ_UNREF(iterator, sip_subscribe_mwi_destroy); + } ASTOBJ_UNLOCK(iterator); } while (0)); } |