summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsip/sip_transport_udp.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/pjsip/src/pjsip/sip_transport_udp.c b/pjsip/src/pjsip/sip_transport_udp.c
index 72acba11..6312756c 100644
--- a/pjsip/src/pjsip/sip_transport_udp.c
+++ b/pjsip/src/pjsip/sip_transport_udp.c
@@ -336,12 +336,16 @@ static pj_status_t udp_destroy( pjsip_transport *transport )
*/
/* Unregister from ioqueue. */
- if (tp->key)
+ if (tp->key) {
pj_ioqueue_unregister(tp->key);
-
- /* Close socket. */
- if (tp->sock && tp->sock != PJ_INVALID_SOCKET)
- pj_sock_close(tp->sock);
+ tp->key = NULL;
+ } else {
+ /* Close socket. */
+ if (tp->sock && tp->sock != PJ_INVALID_SOCKET) {
+ pj_sock_close(tp->sock);
+ tp->sock = PJ_INVALID_SOCKET;
+ }
+ }
/* Must poll ioqueue because IOCP calls the callback when socket
* is closed. We poll the ioqueue until all pending callbacks