[asterisk-commits] mjordan: branch 13 r424601 - /branches/13/res/res_pjsip_pubsub.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Oct 5 19:06:55 CDT 2014
Author: mjordan
Date: Sun Oct 5 19:06:45 2014
New Revision: 424601
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=424601
Log:
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
Modified:
branches/13/res/res_pjsip_pubsub.c
Modified: branches/13/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_pjsip_pubsub.c?view=diff&rev=424601&r1=424600&r2=424601
==============================================================================
--- branches/13/res/res_pjsip_pubsub.c (original)
+++ branches/13/res/res_pjsip_pubsub.c Sun Oct 5 19:06:45 2014
@@ -1038,8 +1038,10 @@
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;
}
}
@@ -1141,6 +1143,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) {
@@ -1357,6 +1363,11 @@
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 {
More information about the asterisk-commits
mailing list