<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7613">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_pjsip.c: Improve ast_request() diagnostic msgs.<br><br>Attempting to dial PJSIP/endpoint when the endpoint doesn't exist and<br>disable_multi_domain=no results in a misleading empty endpoint name<br>message. The message should say the endpoint was not found.<br><br>* Added missing endpoint not found message.<br><br>* Added more information to the empty endpoint name msgs if available.<br><br>* Eliminated RAII_VAR in request().<br><br>Change-Id: I21da85ebd62dcc32115b2ffcb5157416ebae51e4<br>---<br>M channels/chan_pjsip.c<br>1 file changed, 36 insertions(+), 10 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/13/7613/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c<br>index 69bcc18..10f45a4 100644<br>--- a/channels/chan_pjsip.c<br>+++ b/channels/chan_pjsip.c<br>@@ -2381,7 +2381,7 @@<br> struct request_data *req_data = obj;<br> struct ast_sip_session *session = NULL;<br> char *tmp = ast_strdupa(req_data->dest), *endpoint_name = NULL, *request_user = NULL;<br>- RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);<br>+ struct ast_sip_endpoint *endpoint;<br> <br> AST_DECLARE_APP_ARGS(args,<br> AST_APP_ARG(endpoint);<br>@@ -2406,10 +2406,18 @@<br> }<br> <br> if (ast_strlen_zero(endpoint_name)) {<br>- ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name\n");<br>+ if (request_user) {<br>+ ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name: %s@<endpoint-name>\n",<br>+ request_user);<br>+ } else {<br>+ ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name\n");<br>+ }<br> req_data->cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;<br> return -1;<br>- } else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name))) {<br>+ }<br>+ endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint",<br>+ endpoint_name);<br>+ if (!endpoint) {<br> ast_log(LOG_ERROR, "Unable to create PJSIP channel - endpoint '%s' was not found\n", endpoint_name);<br> req_data->cause = AST_CAUSE_NO_ROUTE_DESTINATION;<br> return -1;<br>@@ -2421,23 +2429,38 @@<br> ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name\n");<br> req_data->cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;<br> return -1;<br>- } else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name))) {<br>+ }<br>+ endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint",<br>+ endpoint_name);<br>+ if (!endpoint) {<br> /* It seems it's not a multi-domain endpoint or single endpoint exact match,<br> * it's possible that it's a SIP trunk with a specified user (user@trunkname),<br> * so extract the user before @ sign.<br> */<br>- if ((endpoint_name = strchr(args.endpoint, '@'))) {<br>- request_user = args.endpoint;<br>- *endpoint_name++ = '\0';<br>+ endpoint_name = strchr(args.endpoint, '@');<br>+ if (!endpoint_name) {<br>+ /*<br>+ * Couldn't find an '@' so it had to be an endpoint<br>+ * name that doesn't exist.<br>+ */<br>+ ast_log(LOG_ERROR, "Unable to create PJSIP channel - endpoint '%s' was not found\n",<br>+ args.endpoint);<br>+ req_data->cause = AST_CAUSE_NO_ROUTE_DESTINATION;<br>+ return -1;<br> }<br>+ request_user = args.endpoint;<br>+ *endpoint_name++ = '\0';<br> <br> if (ast_strlen_zero(endpoint_name)) {<br>- ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name\n");<br>+ ast_log(LOG_ERROR, "Unable to create PJSIP channel with empty endpoint name: %s@<endpoint-name>\n",<br>+ request_user);<br> req_data->cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;<br> return -1;<br> }<br> <br>- if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name))) {<br>+ endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint",<br>+ endpoint_name);<br>+ if (!endpoint) {<br> ast_log(LOG_ERROR, "Unable to create PJSIP channel - endpoint '%s' was not found\n", endpoint_name);<br> req_data->cause = AST_CAUSE_NO_ROUTE_DESTINATION;<br> return -1;<br>@@ -2445,7 +2468,10 @@<br> }<br> }<br> <br>- if (!(session = ast_sip_session_create_outgoing(endpoint, NULL, args.aor, request_user, req_data->topology))) {<br>+ session = ast_sip_session_create_outgoing(endpoint, NULL, args.aor, request_user,<br>+ req_data->topology);<br>+ ao2_ref(endpoint, -1);<br>+ if (!session) {<br> ast_log(LOG_ERROR, "Failed to create outgoing session to endpoint '%s'\n", endpoint_name);<br> req_data->cause = AST_CAUSE_NO_ROUTE_DESTINATION;<br> return -1;<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7613">change 7613</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7613"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I21da85ebd62dcc32115b2ffcb5157416ebae51e4 </div>
<div style="display:none"> Gerrit-Change-Number: 7613 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>