Skip to content

Commit 797f1a3

Browse files
author
François-Simon Fauteux-Chapleau
committed
turn_sock: don't try to use a socket that's being deleted
Change-Id: Ia94af25b9be9c9acdb0287674e533c1f72a4a5db
1 parent e12ea3b commit 797f1a3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pjnath/src/pjnath/turn_sock.c

+8
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,14 @@ static pj_bool_t dataconn_on_connect_complete(pj_activesock_t *asock,
16691669

16701670
pj_grp_lock_acquire(turn_sock->grp_lock);
16711671

1672+
if (pj_turn_sock_get_user_data(turn_sock) == NULL) {
1673+
// It's possible for a TURN socket to be destroyed by ice_close_remaining_tcp
1674+
// after the on_connect_complete event has been put into an ioqueue, but
1675+
// before the callback is actually called, so we need to check for this.
1676+
PJ_LOG(4,(turn_sock->obj_name, "Socket is being destroyed, can't be used to establish a data connection"));
1677+
status = PJ_ECANCELLED;
1678+
}
1679+
16721680
if (status == PJ_SUCCESS) {
16731681
status = pj_activesock_start_read(asock, turn_sock->pool,
16741682
turn_sock->setting.max_pkt_size, 0);

0 commit comments

Comments
 (0)