From 685a0b310f66985a606e15b2bc5f65b14a4cf401 Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Tue, 19 Feb 2013 16:20:17 +0100 Subject: [PATCH] Fix uPnP dead lock --- coreapi/upnp.c | 62 ++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/coreapi/upnp.c b/coreapi/upnp.c index deb096b9..4f56e0c1 100644 --- a/coreapi/upnp.c +++ b/coreapi/upnp.c @@ -661,6 +661,11 @@ int linphone_upnp_call_process(LinphoneCall *call) { */ linphone_upnp_update_stream_state(call->upnp_session->video); + /* + * Update stat + */ + linphone_core_update_upnp_state_in_call_stats(call); + /* * Update session state */ @@ -678,41 +683,34 @@ int linphone_upnp_call_process(LinphoneCall *call) { call->upnp_session->state = LinphoneUpnpStateIdle; } newState = call->upnp_session->state; - - /* When change is done proceed update */ - if(oldState != LinphoneUpnpStateOk && oldState != LinphoneUpnpStateKo && - (call->upnp_session->state == LinphoneUpnpStateOk || call->upnp_session->state == LinphoneUpnpStateKo)) { - if(call->upnp_session->state == LinphoneUpnpStateOk) - ms_message("uPnP IGD: uPnP for Call %p is ok", call); - else - ms_message("uPnP IGD: uPnP for Call %p is ko", call); - - switch (call->state) { - case LinphoneCallUpdating: - linphone_core_start_update_call(lc, call); - break; - case LinphoneCallUpdatedByRemote: - linphone_core_start_accept_call_update(lc, call); - break; - case LinphoneCallOutgoingInit: - linphone_core_proceed_with_invite_if_ready(lc, call, NULL); - break; - case LinphoneCallIdle: - linphone_core_notify_incoming_call(lc, call); - break; - default: - break; - } - } } ms_mutex_unlock(&lupnp->mutex); - - /* - * Update uPnP call stats - */ - if(oldState != newState) { - linphone_core_update_upnp_state_in_call_stats(call); + + /* When change is done proceed update */ + if(oldState != LinphoneUpnpStateOk && oldState != LinphoneUpnpStateKo && + (newState == LinphoneUpnpStateOk || newState == LinphoneUpnpStateKo)) { + if(call->upnp_session->state == LinphoneUpnpStateOk) + ms_message("uPnP IGD: uPnP for Call %p is ok", call); + else + ms_message("uPnP IGD: uPnP for Call %p is ko", call); + + switch (call->state) { + case LinphoneCallUpdating: + linphone_core_start_update_call(lc, call); + break; + case LinphoneCallUpdatedByRemote: + linphone_core_start_accept_call_update(lc, call); + break; + case LinphoneCallOutgoingInit: + linphone_core_proceed_with_invite_if_ready(lc, call, NULL); + break; + case LinphoneCallIdle: + linphone_core_notify_incoming_call(lc, call); + break; + default: + break; + } } return ret; -- 2.39.2