[Asterisk-code-review] chan pjsip.c: Improve answer failure log messages. (asterisk[master])

Joshua Colp asteriskteam at digium.com
Thu Nov 16 10:11:32 CST 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/7236 )

Change subject: chan_pjsip.c: Improve answer failure log messages.
......................................................................

chan_pjsip.c: Improve answer failure log messages.

* Balanced the session->inv_session refs on answer failure.

Change-Id: I33542d639d37e692cb46550b972a5fcfc3b804b8
---
M channels/chan_pjsip.c
1 file changed, 21 insertions(+), 4 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  George Joseph: Looks good to me, approved



diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 0160425..e4e8fa5 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -672,7 +672,19 @@
 	pjsip_inv_dec_ref(session->inv_session);
 #endif
 
-	return (status == PJ_SUCCESS) ? 0 : -1;
+	if (status != PJ_SUCCESS) {
+		char err[PJ_ERR_MSG_SIZE];
+
+		pj_strerror(status, err, sizeof(err));
+		ast_log(LOG_WARNING,"Cannot answer '%s': %s\n",
+			ast_channel_name(session->channel), err);
+		/*
+		 * Return this value so we can distinguish between this
+		 * failure and the threadpool synchronous push failing.
+		 */
+		return -2;
+	}
+	return 0;
 }
 
 /*! \brief Function called by core when we should answer a PJSIP session */
@@ -680,6 +692,7 @@
 {
 	struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast);
 	struct ast_sip_session *session;
+	int res;
 
 	if (ast_channel_state(ast) == AST_STATE_UP) {
 		return 0;
@@ -700,11 +713,15 @@
 	   can occur between this thread and bridging (specifically when native bridging
 	   attempts to do direct media) */
 	ast_channel_unlock(ast);
-	if (ast_sip_push_task_synchronous(session->serializer, answer, session)) {
-		ast_log(LOG_WARNING, "Unable to push answer task to the threadpool. Cannot answer call\n");
+	res = ast_sip_push_task_synchronous(session->serializer, answer, session);
+	if (res) {
+		if (res == -1) {
+			ast_log(LOG_ERROR,"Cannot answer '%s': Unable to push answer task to the threadpool.\n",
+				ast_channel_name(session->channel));
 #ifdef HAVE_PJSIP_INV_SESSION_REF
-		pjsip_inv_dec_ref(session->inv_session);
+			pjsip_inv_dec_ref(session->inv_session);
 #endif
+		}
 		ao2_ref(session, -1);
 		ast_channel_lock(ast);
 		return -1;

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I33542d639d37e692cb46550b972a5fcfc3b804b8
Gerrit-Change-Number: 7236
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171116/fbaff917/attachment.html>


More information about the asterisk-code-review mailing list