[asterisk-commits] res pjsip: Record the serializer earlier on the tdata. (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 21 21:17:25 CST 2017


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5028 )

Change subject: res_pjsip: Record the serializer earlier on the tdata.
......................................................................


res_pjsip: Record the serializer earlier on the tdata.

When PJPROJECT needs to do a DNS resolution and there is not a cached
entry available, the SIP request message goes out on the PJSIP monitor
thread instead of the original serializer thread.  Thus when the response
comes back it does not get processed by the original sending serializer.

This patch records the serializer on tdata before passing a request
message to PJPROJECT where it can in Asterisk code.  There are several
places in PJPROJECT for outbound registration and publishing support that
would need to record the serializer.  Unfortunately, without replacing the
PJPROJECT DNS resolver as was done in v14 we cannot fix those without
modifying PJPROJECT.

Even if we backported the DNS resolver from v14, the outbound registration
refresh timer does not go out on a serializer thread but the PJSIP monitor
thread.  Fortunately, Asterisk's outbound publish support doesn't use the
auto refresh timer that would also not go out under the serializer thread.

This patch is v13 only.

ASTERISK-26669
ASTERISK-26738

Change-Id: I9997b9ed6dbcebd2c37d6a67dc6dcee9c78914a4
---
M include/asterisk/res_pjsip.h
M res/res_pjsip.c
M res/res_pjsip/pjsip_distributor.c
M res/res_pjsip_outbound_publish.c
M res/res_pjsip_outbound_registration.c
5 files changed, 18 insertions(+), 12 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, approved
  Mark Michelson: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified



diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index c97e4b5..d8e172f 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -1368,6 +1368,16 @@
 struct ast_taskprocessor *ast_sip_get_distributor_serializer(pjsip_rx_data *rdata);
 
 /*!
+ * \brief Record the task's serializer name on the tdata structure.
+ * \since 13.15.0
+ *
+ * \param tdata The outgoing message.
+ *
+ * \retval PJ_SUCCESS.
+ */
+pj_status_t ast_sip_record_request_serializer(pjsip_tx_data *tdata);
+
+/*!
  * \brief Set a serializer on a SIP dialog so requests and responses are automatically serialized
  *
  * Passing a NULL serializer is a way to remove a serializer from a dialog.
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 9b99058..a167150 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -3603,6 +3603,8 @@
 		}
 	}
 
+	ast_sip_record_request_serializer(tdata);
+
 	/* We need to insure that the wrapper and tdata are available when the
 	 * transaction callback is executed.
 	 */
diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c
index 82ca184..e076db3 100644
--- a/res/res_pjsip/pjsip_distributor.c
+++ b/res/res_pjsip/pjsip_distributor.c
@@ -29,12 +29,11 @@
 
 static int distribute(void *data);
 static pj_bool_t distributor(pjsip_rx_data *rdata);
-static pj_status_t record_serializer(pjsip_tx_data *tdata);
 
 static pjsip_module distributor_mod = {
 	.name = {"Request Distributor", 19},
 	.priority = PJSIP_MOD_PRIORITY_TSX_LAYER - 6,
-	.on_tx_request = record_serializer,
+	.on_tx_request = ast_sip_record_request_serializer,
 	.on_rx_request = distributor,
 	.on_rx_response = distributor,
 };
@@ -65,16 +64,7 @@
 /*! Pool of serializers to use if not supplied. */
 static struct ast_taskprocessor *distributor_pool[DISTRIBUTOR_POOL_SIZE];
 
-/*!
- * \internal
- * \brief Record the task's serializer name on the tdata structure.
- * \since 14.0.0
- *
- * \param tdata The outgoing message.
- *
- * \retval PJ_SUCCESS.
- */
-static pj_status_t record_serializer(pjsip_tx_data *tdata)
+pj_status_t ast_sip_record_request_serializer(pjsip_tx_data *tdata)
 {
 	struct ast_taskprocessor *serializer;
 
diff --git a/res/res_pjsip_outbound_publish.c b/res/res_pjsip_outbound_publish.c
index 35eedf0..7c0b64b 100644
--- a/res/res_pjsip_outbound_publish.c
+++ b/res/res_pjsip_outbound_publish.c
@@ -349,6 +349,7 @@
 			pjsip_tx_data_set_transport(tdata, &selector);
 		}
 
+		ast_sip_record_request_serializer(tdata);
 		pjsip_publishc_send(client->client, tdata);
 	}
 
@@ -598,6 +599,7 @@
 		pjsip_tx_data_set_transport(tdata, &selector);
 	}
 
+	ast_sip_record_request_serializer(tdata);
 	status = pjsip_publishc_send(client->client, tdata);
 	if (status == PJ_EBUSY) {
 		/* We attempted to send the message but something else got there first */
@@ -910,6 +912,7 @@
 				pjsip_tx_data_set_transport(tdata, &selector);
 			}
 
+			ast_sip_record_request_serializer(tdata);
 			pjsip_publishc_send(client->client, tdata);
 		}
 		client->auth_attempts++;
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index da15f19..6c615f0 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -528,6 +528,7 @@
 	 */
 	ast_sip_set_tpselector_from_transport_name(client_state->transport_name, &selector);
 	pjsip_regc_set_transport(client_state->client, &selector);
+	ast_sip_record_request_serializer(tdata);
 	status = pjsip_regc_send(client_state->client, tdata);
 
 	/* If the attempt to send the message failed and the callback was not invoked we need to

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9997b9ed6dbcebd2c37d6a67dc6dcee9c78914a4
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list