Skip to content

Commit 5230107

Browse files
committed
MT#55283 refcount ICE stream_fds
There seems to be a race condition with stream_fds/sockets being closed while ICE checks are running at the same time, referencing the same stream_fds. Solve this by holding a reference to the stream_fd in the ICE pair object. Additionally, add a check for a possibly closed socket when running checks. Closes #2113 Change-Id: I279a62d9e52cb1d409bcfda871766002aac4a758 (cherry picked from commit ceb7996)
1 parent 53a08ff commit 5230107

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

daemon/ice.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static struct ice_candidate_pair *__pair_candidate(stream_fd *sfd, struct ice_ag
285285
pair->agent = ag;
286286
pair->remote_candidate = cand;
287287
pair->local_intf = sfd->local_intf;
288-
pair->sfd = sfd;
288+
pair->sfd = obj_get(sfd);
289289
if (cand->component_id != 1)
290290
PAIR_SET(pair, FROZEN);
291291
__do_ice_pair_priority(pair);
@@ -637,6 +637,7 @@ void ice_candidates_free(candidate_q *q) {
637637
t_queue_clear_full(q, ice_candidate_free);
638638
}
639639
static void ice_candidate_pair_free(struct ice_candidate_pair *p) {
640+
obj_release(p->sfd);
640641
g_free(p);
641642
}
642643
static void ice_candidate_pairs_free(candidate_pair_q *q) {
@@ -893,7 +894,7 @@ static void __do_ice_checks(struct ice_agent *ag) {
893894

894895
/* skip dead streams */
895896
sfd = pair->sfd;
896-
if (!sfd || !sfd->stream || !sfd->stream->selected_sfd)
897+
if (!sfd || !sfd->stream || !sfd->stream->selected_sfd || !sfd->socket.family)
897898
continue;
898899
if (PAIR_ISSET(pair, FAILED))
899900
continue;

0 commit comments

Comments
 (0)