From e164d1500a275ac051dcb9798838e2385d496355 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 29 Nov 2013 00:33:05 +0000 Subject: 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 --- pjsip/src/pjsip/sip_transport_tcp.c | 6 +++++- pjsip/src/pjsip/sip_transport_tls.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'pjsip') 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 -- cgit v1.2.3