[svn-commits] file: branch file/pjsip-outbound-publish r419128 - /team/file/pjsip-outbound-...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jul 22 07:09:42 CDT 2014


Author: file
Date: Tue Jul 22 07:09:30 2014
New Revision: 419128

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=419128
Log:
Incorporate review feedback. Only do URI validation on off-nominal case if PJSIP reports a URI is invalid.

Modified:
    team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c

Modified: team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c?view=diff&rev=419128&r1=419127&r2=419128
==============================================================================
--- team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c (original)
+++ team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c Tue Jul 22 07:09:30 2014
@@ -527,53 +527,11 @@
 static int sip_outbound_publish_client_alloc(void *data)
 {
 	struct ast_sip_outbound_publish *publish = data;
-	pj_pool_t *pool;
-	pj_str_t tmp;
-	pjsip_uri *uri;
 	pjsip_publishc_opt opt = {
 		.queue_request = PJ_FALSE,
 	};
 	pj_str_t event, server_uri, to_uri, from_uri;
-
-	pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "URI Validation", 256, 256);
-	if (!pool) {
-		ast_log(LOG_ERROR, "Could not create pool for URI validation on outbound publish '%s'\n",
-			ast_sorcery_object_get_id(publish));
-		return -1;
-	}
-
-	pj_strdup2_with_null(pool, &tmp, publish->server_uri);
-	uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0);
-	if (!uri) {
-		ast_log(LOG_ERROR, "Invalid server URI '%s' specified on outbound publish '%s'\n",
-			publish->server_uri, ast_sorcery_object_get_id(publish));
-		pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
-		return -1;
-	}
-
-	if (!ast_strlen_zero(publish->to_uri)) {
-		pj_strdup2_with_null(pool, &tmp, publish->to_uri);
-		uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0);
-		if (!uri) {
-			ast_log(LOG_ERROR, "Invalid to URI '%s' specified on outbound publish '%s'\n",
-				publish->to_uri, ast_sorcery_object_get_id(publish));
-			pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
-			return -1;
-		}
-	}
-
-	if (!ast_strlen_zero(publish->from_uri)) {
-		pj_strdup2_with_null(pool, &tmp, publish->from_uri);
-		uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0);
-		if (!uri) {
-			ast_log(LOG_ERROR, "Invalid from URI '%s' specified on outbound publish '%s'\n",
-				publish->from_uri, ast_sorcery_object_get_id(publish));
-			pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
-			return -1;
-		}
-	}
-
-	pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
+	pj_status_t status;
 
 	if (!publish->state->client &&
 		pjsip_publishc_create(ast_sip_get_pjsip_endpoint(), &opt, publish, sip_outbound_publish_callback,
@@ -601,8 +559,48 @@
 	pj_cstr(&to_uri, S_OR(publish->to_uri, publish->server_uri));
 	pj_cstr(&from_uri, S_OR(publish->from_uri, publish->server_uri));
 
-	if (pjsip_publishc_init(publish->state->client, &event, &server_uri, &from_uri, &to_uri,
-		publish->expiration) != PJ_SUCCESS) {
+	status = pjsip_publishc_init(publish->state->client, &event, &server_uri, &from_uri, &to_uri,
+		publish->expiration);
+	if (status == PJSIP_EINVALIDURI) {
+		pj_pool_t *pool;
+		pj_str_t tmp;
+		pjsip_uri *uri;
+
+		pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "URI Validation", 256, 256);
+		if (!pool) {
+			ast_log(LOG_ERROR, "Could not create pool for URI validation on outbound publish '%s'\n",
+				ast_sorcery_object_get_id(publish));
+			return -1;
+		}
+
+		pj_strdup2_with_null(pool, &tmp, publish->server_uri);
+		uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0);
+		if (!uri) {
+			ast_log(LOG_ERROR, "Invalid server URI '%s' specified on outbound publish '%s'\n",
+				publish->server_uri, ast_sorcery_object_get_id(publish));
+		}
+
+		if (!ast_strlen_zero(publish->to_uri)) {
+			pj_strdup2_with_null(pool, &tmp, publish->to_uri);
+			uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0);
+			if (!uri) {
+				ast_log(LOG_ERROR, "Invalid to URI '%s' specified on outbound publish '%s'\n",
+					publish->to_uri, ast_sorcery_object_get_id(publish));
+			}
+		}
+
+		if (!ast_strlen_zero(publish->from_uri)) {
+			pj_strdup2_with_null(pool, &tmp, publish->from_uri);
+			uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0);
+			if (!uri) {
+				ast_log(LOG_ERROR, "Invalid from URI '%s' specified on outbound publish '%s'\n",
+					publish->from_uri, ast_sorcery_object_get_id(publish));
+			}
+		}
+
+		pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
+		return -1;
+	} else if (status != PJ_SUCCESS) {
 		return -1;
 	}
 




More information about the svn-commits mailing list