[Asterisk-code-review] res pjsip pubsub: Correctly implement persisted subscriptions (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Tue Feb 14 17:11:02 CST 2017


Richard Mudgett has posted comments on this change. ( https://gerrit.asterisk.org/4916 )

Change subject: res_pjsip_pubsub:  Correctly implement persisted subscriptions
......................................................................


Patch Set 6: Code-Review-1

(1 comment)

https://gerrit.asterisk.org/#/c/4916/6/res/res_pjsip_pubsub.c
File res/res_pjsip_pubsub.c:

PS6, Line 2863: 		ind->sub_tree->expiration_task = ast_sip_schedule_task(ind->sub_tree->serializer,
              : 			ind->expires * 1000, serialized_pubsub_on_refresh_timeout, name,
              : 			ao2_bump(ind->sub_tree), AST_SIP_SCHED_TASK_FIXED);
The ind->sub_tree refs are handled unsafely.  Canceling the timer will ref leak ind->sub_tree that you are trying to pass to the callback function.

I think you can fix it this way:

Pass AST_SIP_SCHED_TASK_FIXED | AST_SIP_SCHED_TASK_DATA_AO2

The AO2 flag is so the sub_tree ref is handled inside the scheduler safely.

There are two versions of serialized_pubsub_on_refresh_timeout() needed.  One that unrefs the passed in sub_tree and the other that doesn't.  Each could be done in terms of the other.  For the scheduled timeout function here would need the one that doesn't unref sub_tree.

Letting the scheduler hold a sub_tree ref will definitely prevent any expiration_task from being valid in the sub_tree destructor.


-- 
To view, visit https://gerrit.asterisk.org/4916
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I8c605fc1e3923f466a74db087d5ab6f90abce68e
Gerrit-PatchSet: 6
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-HasComments: Yes



More information about the asterisk-code-review mailing list