[Asterisk-code-review] chan sip: Give more time for TCP/TLS threads to stop. (asterisk[13])

Anonymous Coward asteriskteam at digium.com
Wed Apr 27 08:50:36 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: chan_sip: Give more time for TCP/TLS threads to stop.
......................................................................


chan_sip: Give more time for TCP/TLS threads to stop.

The unload process currently tells each TCP/TLS to terminate but
does not wait for them to do so. This introduces a race condition
where the container holding the threads may be destroyed before
the threads are able to remove themselves from it. When they
finally do the container is invalid and can't be used causing a
crash.

A previous change existed which waited a bit to wait for any
stranglers to finish. This change extends this and waits longer.

ASTERISK-25961 #close

Change-Id: Idc6262b670ca49ede32061159e323b7b63c6f3c6
---
M channels/chan_sip.c
1 file changed, 4 insertions(+), 4 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve



diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 45827b4..cbbda4e 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -35201,7 +35201,7 @@
 	struct sip_pvt *p;
 	struct sip_threadinfo *th;
 	struct ao2_iterator i;
-	int wait_count;
+	struct timeval start;
 
 	ast_sip_api_provider_unregister();
 
@@ -35351,11 +35351,11 @@
 	 * joinable.  They can die on their own and remove themselves
 	 * from the container thus resulting in a huge memory leak.
 	 */
-	wait_count = 1000;
-	while (ao2_container_count(threadt) && --wait_count) {
+	start = ast_tvnow();
+	while (ao2_container_count(threadt) && (ast_tvdiff_sec(ast_tvnow(), start) < 5)) {
 		sched_yield();
 	}
-	if (!wait_count) {
+	if (ao2_container_count(threadt)) {
 		ast_debug(2, "TCP/TLS thread container did not become empty :(\n");
 	}
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idc6262b670ca49ede32061159e323b7b63c6f3c6
Gerrit-PatchSet: 4
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list