[Asterisk-code-review] chan sip: Ensure TCP/TLS threads are terminated before unloa... (asterisk[master])

Joshua Colp asteriskteam at digium.com
Mon Apr 25 14:44:09 CDT 2016


Joshua Colp has uploaded a new change for review.

  https://gerrit.asterisk.org/2702

Change subject: chan_sip: Ensure TCP/TLS threads are terminated before unloading.
......................................................................

chan_sip: Ensure TCP/TLS threads are terminated before unloading.

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.

This change waits for all the threads to remove themselves before
continuing the unload process.

ASTERISK-25961 #close

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


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/02/2702/1

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index d927f06..1556915 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -35369,6 +35369,11 @@
 	}
 	ao2_iterator_destroy(&i);
 
+	/* Wait for the existing TCP/TLS threads to stop */
+	while (ao2_container_count(threadt)) {
+		usleep(1);
+	}
+
 	/* Hangup all dialogs if they have an owner */
 	i = ao2_iterator_init(dialogs, 0);
 	while ((p = ao2_t_iterator_next(&i, "iterate thru dialogs"))) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc6262b670ca49ede32061159e323b7b63c6f3c6
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list