[asterisk-commits] mmichelson: branch mmichelson/pub_sub r385816 - /team/mmichelson/pub_sub/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Apr 15 15:08:34 CDT 2013
Author: mmichelson
Date: Mon Apr 15 15:08:30 2013
New Revision: 385816
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385816
Log:
Correct refcounting for solicited MWI.
The references work like this:
Stasis holds a reference to the MWI subscription, which
holds a reference to the pubsub subscription. When the SIP
subscription terminates, we unsubscribe from stasis. When
stasis sends its final message to us, we can then lose stasis's
reference to the MWI subscription, which causes destruction
down the chain.
With this improvement, MWI is functional. Remaining tasks
are just to do code cleanup and documentation.
Modified:
team/mmichelson/pub_sub/res/res_sip_mwi.c
team/mmichelson/pub_sub/res/res_sip_pubsub.c
Modified: team/mmichelson/pub_sub/res/res_sip_mwi.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pub_sub/res/res_sip_mwi.c?view=diff&rev=385816&r1=385815&r2=385816
==============================================================================
--- team/mmichelson/pub_sub/res/res_sip_mwi.c (original)
+++ team/mmichelson/pub_sub/res/res_sip_mwi.c Mon Apr 15 15:08:30 2013
@@ -298,9 +298,28 @@
}
}
+static int unsubscribe_stasis(void *obj, void *arg, int flags)
+{
+ struct mwi_stasis_subscription *mwi_stasis = obj;
+ if (mwi_stasis->stasis_sub) {
+ ast_log(LOG_NOTICE, "Removing stasis subscription\n");
+ mwi_stasis->stasis_sub = stasis_unsubscribe(mwi_stasis->stasis_sub);
+ }
+ return CMP_MATCH;
+}
+
static void mwi_subscription_shutdown(struct ast_sip_subscription *sub)
{
- /* XXX STUB */
+ struct mwi_subscription *mwi_sub;
+ RAII_VAR(struct ast_datastore *, mwi_datastore,
+ ast_sip_subscription_get_datastore(sub, "MWI datastore"), ao2_cleanup);
+
+ if (!mwi_datastore) {
+ return;
+ }
+
+ mwi_sub = mwi_datastore->data;
+ ao2_callback(mwi_sub->stasis_subs, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, unsubscribe_stasis, NULL);
}
static struct ast_datastore_info mwi_ds_info = { };
@@ -437,6 +456,7 @@
struct mwi_subscription *mwi_sub = userdata;
send_mwi_notify(mwi_sub, PJSIP_EVSUB_STATE_ACTIVE, NULL);
+ ao2_ref(mwi_sub, -1);
return 0;
}
@@ -452,6 +472,7 @@
if (stasis_mwi_state_type() == stasis_message_type(msg)) {
struct ast_taskprocessor *serializer = mwi_sub->is_solicited ? ast_sip_subscription_get_serializer(mwi_sub->sip_sub) : NULL;
+ ao2_ref(mwi_sub, +1);
ast_sip_push_task(serializer, serialized_notify, mwi_sub);
}
}
@@ -496,15 +517,6 @@
return 0;
}
-static int unsubscribe_stasis(void *obj, void *arg, int flags)
-{
- struct mwi_stasis_subscription *mwi_stasis = obj;
- if (mwi_stasis->stasis_sub) {
- mwi_stasis->stasis_sub = stasis_unsubscribe(mwi_stasis->stasis_sub);
- }
- return CMP_MATCH;
-}
-
static int unsubscribe(void *obj, void *arg, int flags)
{
struct mwi_subscription *mwi_sub = obj;
Modified: team/mmichelson/pub_sub/res/res_sip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pub_sub/res/res_sip_pubsub.c?view=diff&rev=385816&r1=385815&r2=385816
==============================================================================
--- team/mmichelson/pub_sub/res/res_sip_pubsub.c (original)
+++ team/mmichelson/pub_sub/res/res_sip_pubsub.c Mon Apr 15 15:08:30 2013
@@ -449,7 +449,6 @@
sub->handler->subscription_shutdown(sub);
}
pjsip_evsub_set_mod_data(evsub, sub_module.id, NULL);
- ao2_ref(sub, -1);
}
static void pubsub_on_tsx_state(pjsip_evsub *evsub, pjsip_transaction *tsx, pjsip_event *event)
More information about the asterisk-commits
mailing list