summaryrefslogtreecommitdiff
path: root/res/res_pjsip_pubsub.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2014-10-06 00:06:45 +0000
committerMatthew Jordan <mjordan@digium.com>2014-10-06 00:06:45 +0000
commitf36b64f58e1799383bf20292e90d5bc490d2ce90 (patch)
tree4567d279b80b4aca7639a97387120b5da60bb4dd /res/res_pjsip_pubsub.c
parent9e3b5be1820cc2d1403258742c1a6a8758acdf32 (diff)
res/res_pjsip_pubsub: Gracefully handle errors when re-creating subscriptions
A subscription that has been persisted can - for various reasons - fail to be re-created on startup. This patch resolves a number of crashes that occurred when a subscription cannot be re-created on several off-nominal paths. #SIPit31 ASTERISK-24368 #close Reported by: Matt Jordan git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@424601 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_pubsub.c')
-rw-r--r--res/res_pjsip_pubsub.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index b4d0be98d..5f99a1530 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -1038,8 +1038,10 @@ static void remove_subscription(struct sip_subscription_tree *obj)
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&subscriptions, i, next) {
if (i == obj) {
AST_RWLIST_REMOVE_CURRENT(next);
- ast_debug(1, "Removing subscription to resource %s from list of subscriptions\n",
- ast_sip_subscription_get_resource_name(i->root));
+ if (i->root) {
+ ast_debug(1, "Removing subscription to resource %s from list of subscriptions\n",
+ ast_sip_subscription_get_resource_name(i->root));
+ }
break;
}
}
@@ -1142,6 +1144,10 @@ static void shutdown_subscriptions(struct ast_sip_subscription *sub)
{
int i;
+ if (!sub) {
+ return;
+ }
+
if (AST_VECTOR_SIZE(&sub->children) > 0) {
for (i = 0; i < AST_VECTOR_SIZE(&sub->children); ++i) {
shutdown_subscriptions(AST_VECTOR_GET(&sub->children, i));
@@ -1357,6 +1363,11 @@ static int subscription_persistence_recreate(void *obj, void *arg, int flags)
ast_sip_pubsub_has_eventlist_support(&rdata));
if (PJSIP_IS_STATUS_IN_CLASS(resp, 200)) {
sub_tree = create_subscription_tree(handler, endpoint, &rdata, resource, generator, &tree);
+ if (!sub_tree) {
+ ast_sorcery_delete(ast_sip_get_sorcery(), persistence);
+ ast_log(LOG_WARNING, "Failed to re-create subscription for %s\n", persistence->endpoint);
+ return 0;
+ }
sub_tree->persistence = ao2_bump(persistence);
subscription_persistence_update(sub_tree, &rdata);
} else {