[svn-commits] file: branch group/pimp_my_sip r392562 - /team/group/pimp_my_sip/res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Jun 22 08:31:23 CDT 2013


Author: file
Date: Sat Jun 22 08:31:21 2013
New Revision: 392562

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392562
Log:
Fix an assert when a partially handled SUBSCRIBE was rejected.

What was happening is the SUBSCRIBE was being handled and a dialog (and transaction)
created. When trying to send a 500 back statelessly the code asserted as it expects
no transaction to exist.

This change terminates the subscription on failure cases and also sends the 500 response
statefully when needed. Once the response is sent and the timer ends everything is
properly destroyed.

Modified:
    team/group/pimp_my_sip/res/res_sip_exten_state.c
    team/group/pimp_my_sip/res/res_sip_pubsub.c

Modified: team/group/pimp_my_sip/res/res_sip_exten_state.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_exten_state.c?view=diff&rev=392562&r1=392561&r2=392562
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_exten_state.c (original)
+++ team/group/pimp_my_sip/res/res_sip_exten_state.c Sat Jun 22 08:31:21 2013
@@ -454,6 +454,7 @@
 		     state_changed, state_changed_destroy, exten_state_sub)) < 0) {
 		ast_log(LOG_WARNING, "Unable to subscribe extension %s\n",
 			exten_state_sub->exten);
+		pjsip_evsub_terminate(ast_sip_subscription_get_evsub(exten_state_sub->sip_sub), PJ_FALSE);
 		return NULL;
 	}
 
@@ -462,12 +463,14 @@
 
 	if (add_datastore(exten_state_sub)) {
 		ast_log(LOG_WARNING, "Unable to add to subscription datastore.\n");
+		pjsip_evsub_terminate(ast_sip_subscription_get_evsub(exten_state_sub->sip_sub), PJ_FALSE);
 		return NULL;
 	}
 
 	if (pjsip_evsub_accept(ast_sip_subscription_get_evsub(exten_state_sub->sip_sub),
 			       rdata, 200, NULL) != PJ_SUCCESS) {
 		ast_log(LOG_WARNING, "Unable to accept the incoming extension state subscription.\n");
+		pjsip_evsub_terminate(ast_sip_subscription_get_evsub(exten_state_sub->sip_sub), PJ_FALSE);
 		return NULL;
 	}
 

Modified: team/group/pimp_my_sip/res/res_sip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_pubsub.c?view=diff&rev=392562&r1=392561&r2=392562
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_pubsub.c (original)
+++ team/group/pimp_my_sip/res/res_sip_pubsub.c Sat Jun 22 08:31:21 2013
@@ -475,7 +475,19 @@
 	}
 	sub = handler->new_subscribe(endpoint, rdata);
 	if (!sub) {
-		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, NULL, NULL);
+		pjsip_transaction *trans = pjsip_rdata_get_tsx(rdata);
+
+		if (trans) {
+			pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata);
+			pjsip_tx_data *tdata;
+
+			if (pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, &tdata) != PJ_SUCCESS) {
+				return PJ_TRUE;
+			}
+			pjsip_dlg_send_response(dlg, trans, tdata);
+		} else {
+			pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, NULL, NULL);
+		}
 	}
 	return PJ_TRUE;
 }




More information about the svn-commits mailing list