[asterisk-commits] file: branch file/pjsip-outbound-publish r419850 - /team/file/pjsip-outbound-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 31 10:16:18 CDT 2014


Author: file
Date: Thu Jul 31 10:16:12 2014
New Revision: 419850

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=419850
Log:
Handle 412 and 423 response codes.

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=419850&r1=419849&r2=419850
==============================================================================
--- team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c (original)
+++ team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c Thu Jul 31 10:16:12 2014
@@ -568,7 +568,49 @@
 
 	ao2_lock(publish->state);
 
-	if (publish->state->sending) {
+	if (param->code == 412) {
+		pjsip_publishc_opt opt = {
+			.queue_request = PJ_FALSE,
+		};
+		pj_str_t event, server_uri, to_uri, from_uri;
+
+		pjsip_publishc_destroy(publish->state->client);
+		if (pjsip_publishc_create(ast_sip_get_pjsip_endpoint(), &opt, publish, sip_outbound_publish_callback,
+			&publish->state->client) != PJ_SUCCESS) {
+			ast_log(LOG_ERROR, "Failed to create a new outbound publish client for '%s' on 412 response\n",
+				ast_sorcery_object_get_id(publish));
+			return;
+		}
+
+		pj_cstr(&event, publish->event);
+		pj_cstr(&server_uri, publish->server_uri);
+		pj_cstr(&to_uri, S_OR(publish->to_uri, publish->server_uri));
+		pj_cstr(&from_uri, S_OR(publish->from_uri, publish->server_uri));
+
+		/* Re-initialize the publish client so it starts with fresh state */
+		if (pjsip_publishc_init(publish->state->client, &event, &server_uri, &from_uri, &to_uri,
+			publish->expiration) != PJ_SUCCESS) {
+			ast_log(LOG_ERROR, "Failed to initialize outbound publish '%s' to send an initial PUBLISH on 412 response\n",
+				ast_sorcery_object_get_id(publish));
+			return;
+		}
+
+		/* Setting this to NULL will cause a new PUBLISH to get created and sent for the same underlying body */
+		publish->state->sending = NULL;
+	} else if (param->code == 423) {
+		/* Update the expiration with the new expiration time if available */
+		pjsip_expires_hdr *expires;
+
+		expires = pjsip_msg_find_hdr(param->rdata->msg_info.msg, PJSIP_H_MIN_EXPIRES, NULL);
+		if (!expires || !expires->ivalue) {
+			ast_log(LOG_ERROR, "Received 402 response on outbound publish '%s' without a Min-Expires header\n",
+				ast_sorcery_object_get_id(publish));
+			return;
+		}
+
+		pjsip_publishc_update_expires(publish->state->client, expires->ivalue);
+		publish->state->sending = NULL;
+	} else if (publish->state->sending) {
 		/* Remove the message currently being sent so that when the queue is serviced another will get sent */
 		AST_LIST_REMOVE_HEAD(&publish->state->queue, entry);
 		ast_free(publish->state->sending);




More information about the asterisk-commits mailing list