summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2013-11-29 00:33:05 +0000
committerBenny Prijono <bennylp@teluu.com>2013-11-29 00:33:05 +0000
commite164d1500a275ac051dcb9798838e2385d496355 (patch)
tree74e7fdf2b4faf284dfd1acfdc995d8c6b7ce77f6
parent831823773e16aff2a237335145effd426d5ebf87 (diff)
Fixed #1714: Workaround for stuck in TCP/TLS shutdown when another thread is destroying the transport
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4661 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip/src/pjsip/sip_transport_tcp.c6
-rw-r--r--pjsip/src/pjsip/sip_transport_tls.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/pjsip/src/pjsip/sip_transport_tcp.c b/pjsip/src/pjsip/sip_transport_tcp.c
index 22359858..e48d5ecc 100644
--- a/pjsip/src/pjsip/sip_transport_tcp.c
+++ b/pjsip/src/pjsip/sip_transport_tcp.c
@@ -176,7 +176,7 @@ static void tcp_init_shutdown(struct tcp_transport *tcp, pj_status_t status)
if (tcp->close_reason == PJ_SUCCESS)
tcp->close_reason = status;
- if (tcp->base.is_shutdown)
+ if (tcp->base.is_shutdown || tcp->base.is_destroying)
return;
/* Prevent immediate transport destroy by application, as transport
@@ -195,6 +195,10 @@ static void tcp_init_shutdown(struct tcp_transport *tcp, pj_status_t status)
(*state_cb)(&tcp->base, PJSIP_TP_STATE_DISCONNECTED, &state_info);
}
+ /* check again */
+ if (tcp->base.is_shutdown || tcp->base.is_destroying)
+ return;
+
/* We can not destroy the transport since high level objects may
* still keep reference to this transport. So we can only
* instruct transport manager to gracefully start the shutdown
diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c
index dc83ab8b..125e9b15 100644
--- a/pjsip/src/pjsip/sip_transport_tls.c
+++ b/pjsip/src/pjsip/sip_transport_tls.c
@@ -183,7 +183,7 @@ static void tls_init_shutdown(struct tls_transport *tls, pj_status_t status)
if (tls->close_reason == PJ_SUCCESS)
tls->close_reason = status;
- if (tls->base.is_shutdown)
+ if (tls->base.is_shutdown || tls->base.is_destroying)
return;
/* Prevent immediate transport destroy by application, as transport
@@ -214,6 +214,10 @@ static void tls_init_shutdown(struct tls_transport *tls, pj_status_t status)
(*state_cb)(&tls->base, PJSIP_TP_STATE_DISCONNECTED, &state_info);
}
+ /* check again */
+ if (tls->base.is_shutdown || tls->base.is_destroying)
+ return;
+
/* We can not destroy the transport since high level objects may
* still keep reference to this transport. So we can only
* instruct transport manager to gracefully start the shutdown