From b0a38982c2eebfe55ec8b4761505d7af17774718 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 29 Jan 2016 14:43:57 -0500 Subject: [PATCH] fix sfd assignments when remote port changes Change-Id: I609d24b8050cc37e42d62aa27c3ecb71c3dbd168 --- daemon/call.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 53bdc123a..f7ce1ead3 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -765,38 +765,44 @@ next_il: } static void __assign_stream_fds(struct call_media *media, GQueue *intf_sfds) { - GList *l, *k, *m; + GList *l, *k; struct packet_stream *ps; - struct stream_fd *sfd; + struct stream_fd *sfd, *intf_sfd; struct intf_list *il; - int first = 1; + int sfd_found; + + for (k = media->streams.head; k; k = k->next) { + ps = k->data; - for (l = intf_sfds->head; l; l = l->next) { - il = l->data; + g_queue_clear(&ps->sfds); + sfd_found = 0; + intf_sfd = NULL; - for (m = il->list.head, k = media->streams.head; m && k; m = m->next, k = k->next) { - sfd = m->data; - ps = k->data; + for (l = intf_sfds->head; l; l = l->next) { + il = l->data; - if (first) - g_queue_clear(&ps->sfds); + sfd = g_queue_peek_nth(&il->list, ps->component - 1); sfd->stream = ps; g_queue_push_tail(&ps->sfds, sfd); - if (!ps->selected_sfd) - ps->selected_sfd = sfd; + if (ps->selected_sfd == sfd) + sfd_found = 1; + if (ps->selected_sfd && sfd->local_intf == ps->selected_sfd->local_intf) + intf_sfd = sfd; + } - /* XXX: - * check whether previous/currect selected_sfd is actually part of - * current sfds list. - * if selected_sfd changes, take previously selected interface into account. - * handle crypto/dtls resets by moving contexts into sfd struct. - * handle ice resets too. - */ + if (!ps->selected_sfd || !sfd_found) { + if (intf_sfd) + ps->selected_sfd = intf_sfd; + else + ps->selected_sfd = g_queue_peek_nth(&ps->sfds, 0); } - first = 0; + /* XXX: + * handle crypto/dtls resets by moving contexts into sfd struct. + * handle ice resets too. + */ } }