[Asterisk-code-review] transport management: Register thread with PJProject. (asterisk[master])

Kevin Harwell asteriskteam at digium.com
Thu Apr 14 14:50:27 CDT 2016


Kevin Harwell has submitted this change and it was merged.

Change subject: transport management: Register thread with PJProject.
......................................................................


transport management: Register thread with PJProject.

The scheduler thread that kills idle TCP connections was not registering
with PJProject properly and causing assertions if PJProject was built in
debug mode.

This change registers the thread with PJProject the first time that the
scheduler callback executes.

AST-2016-005

Change-Id: I5f7a37e2c80726a99afe9dc2a4a69bdedf661283
---
M res/res_pjsip_transport_management.c
1 file changed, 18 insertions(+), 0 deletions(-)

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



diff --git a/res/res_pjsip_transport_management.c b/res/res_pjsip_transport_management.c
index 862ae72..e4ade2b 100644
--- a/res/res_pjsip_transport_management.c
+++ b/res/res_pjsip_transport_management.c
@@ -101,11 +101,29 @@
 	return NULL;
 }
 
+AST_THREADSTORAGE(desc_storage);
+
 static int idle_sched_cb(const void *data)
 {
 	struct monitored_transport *keepalive = (struct monitored_transport *) data;
 	int sip_received = ast_atomic_fetchadd_int(&keepalive->sip_received, 0);
 
+	if (!pj_thread_is_registered()) {
+		pj_thread_t *thread;
+		pj_thread_desc *desc;
+
+		desc = ast_threadstorage_get(&desc_storage, sizeof(pj_thread_desc));
+		if (!desc) {
+			ast_log(LOG_ERROR, "Could not get thread desc from thread-local storage.\n");
+			ao2_ref(keepalive, -1);
+			return 0;
+		}
+
+		pj_bzero(*desc, sizeof(*desc));
+
+		pj_thread_register("Transport Monitor", *desc, &thread);
+	}
+
 	if (!sip_received) {
 		ast_log(LOG_NOTICE, "Shutting down transport '%s' since no request was received in %d seconds\n",
 				keepalive->transport->info, IDLE_TIMEOUT);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5f7a37e2c80726a99afe9dc2a4a69bdedf661283
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-code-review mailing list