Commit a3072137 authored by Yann Diorcet's avatar Yann Diorcet

Fix uPnP context destroy

parent a8f757be
...@@ -93,6 +93,7 @@ void linphone_upnp_update_port_binding(UpnpContext *lupnp, UpnpPortBinding **por ...@@ -93,6 +93,7 @@ void linphone_upnp_update_port_binding(UpnpContext *lupnp, UpnpPortBinding **por
void linphone_upnp_port_binding_log(int level, const char *msg, const UpnpPortBinding *port); void linphone_upnp_port_binding_log(int level, const char *msg, const UpnpPortBinding *port);
void linphone_upnp_port_binding_release(UpnpPortBinding *port); void linphone_upnp_port_binding_release(UpnpPortBinding *port);
void linphone_upnp_update_config(UpnpContext *lupnp); void linphone_upnp_update_config(UpnpContext *lupnp);
void linphone_upnp_update_proxy(UpnpContext *lupnp, bool_t force);
// Configuration // Configuration
MSList *linphone_upnp_config_list_port_bindings(struct _LpConfig *lpc); MSList *linphone_upnp_config_list_port_bindings(struct _LpConfig *lpc);
...@@ -310,12 +311,17 @@ void linphone_upnp_context_destroy(UpnpContext *lupnp) { ...@@ -310,12 +311,17 @@ void linphone_upnp_context_destroy(UpnpContext *lupnp) {
} }
if(lupnp->upnp_igd_ctxt != NULL) { if(lupnp->upnp_igd_ctxt != NULL) {
// upnp_igd_destroy is synchronous so the callbacks will be called in the same thread.
// So release the mutex before upnp_igd_destroy call.
ms_mutex_unlock(&lupnp->mutex);
upnp_igd_destroy(lupnp->upnp_igd_ctxt); upnp_igd_destroy(lupnp->upnp_igd_ctxt);
ms_mutex_lock(&lupnp->mutex);
lupnp->upnp_igd_ctxt = NULL; lupnp->upnp_igd_ctxt = NULL;
} }
/* Run one more time configuration update */ /* Run one more time configuration update and proxy */
linphone_upnp_update_config(lupnp); linphone_upnp_update_config(lupnp);
linphone_upnp_update_proxy(lupnp, TRUE);
/* Release port bindings */ /* Release port bindings */
if(lupnp->sip_udp != NULL) { if(lupnp->sip_udp != NULL) {
...@@ -858,23 +864,11 @@ void linphone_upnp_update_config(UpnpContext* lupnp) { ...@@ -858,23 +864,11 @@ void linphone_upnp_update_config(UpnpContext* lupnp) {
lupnp->removing_configs = ms_list_free(lupnp->removing_configs); lupnp->removing_configs = ms_list_free(lupnp->removing_configs);
} }
bool_t linphone_core_upnp_hook(void *data) { void linphone_upnp_update_proxy(UpnpContext* lupnp, bool_t force) {
LCSipTransports transport;
LinphoneUpnpState ready_state; LinphoneUpnpState ready_state;
const MSList *item; const MSList *item;
time_t now = time(NULL); time_t now = (force)? (lupnp->last_ready_check + UPNP_CORE_READY_CHECK) : time(NULL);
UpnpContext *lupnp = (UpnpContext *)data;
ms_mutex_lock(&lupnp->mutex);
/* Update ports */
if(lupnp->state == LinphoneUpnpStateOk) {
linphone_core_get_sip_transports(lupnp->lc, &transport);
linphone_upnp_update_port_binding(lupnp, &lupnp->sip_udp, UPNP_IGD_IP_PROTOCOL_UDP, transport.udp_port, UPNP_CORE_RETRY_DELAY);
linphone_upnp_update_port_binding(lupnp, &lupnp->sip_tcp, UPNP_IGD_IP_PROTOCOL_TCP, transport.tcp_port, UPNP_CORE_RETRY_DELAY);
linphone_upnp_update_port_binding(lupnp, &lupnp->sip_tls, UPNP_IGD_IP_PROTOCOL_TCP, transport.tls_port, UPNP_CORE_RETRY_DELAY);
}
/* Refresh registers if we are ready */ /* Refresh registers if we are ready */
if(now - lupnp->last_ready_check >= UPNP_CORE_READY_CHECK) { if(now - lupnp->last_ready_check >= UPNP_CORE_READY_CHECK) {
lupnp->last_ready_check = now; lupnp->last_ready_check = now;
...@@ -896,7 +890,23 @@ bool_t linphone_core_upnp_hook(void *data) { ...@@ -896,7 +890,23 @@ bool_t linphone_core_upnp_hook(void *data) {
lupnp->last_ready_state = ready_state; lupnp->last_ready_state = ready_state;
} }
} }
}
bool_t linphone_core_upnp_hook(void *data) {
LCSipTransports transport;
UpnpContext *lupnp = (UpnpContext *)data;
ms_mutex_lock(&lupnp->mutex);
/* Update ports */
if(lupnp->state == LinphoneUpnpStateOk) {
linphone_core_get_sip_transports(lupnp->lc, &transport);
linphone_upnp_update_port_binding(lupnp, &lupnp->sip_udp, UPNP_IGD_IP_PROTOCOL_UDP, transport.udp_port, UPNP_CORE_RETRY_DELAY);
linphone_upnp_update_port_binding(lupnp, &lupnp->sip_tcp, UPNP_IGD_IP_PROTOCOL_TCP, transport.tcp_port, UPNP_CORE_RETRY_DELAY);
linphone_upnp_update_port_binding(lupnp, &lupnp->sip_tls, UPNP_IGD_IP_PROTOCOL_TCP, transport.tls_port, UPNP_CORE_RETRY_DELAY);
}
linphone_upnp_update_proxy(lupnp, FALSE);
linphone_upnp_update_config(lupnp); linphone_upnp_update_config(lupnp);
ms_mutex_unlock(&lupnp->mutex); ms_mutex_unlock(&lupnp->mutex);
......
mediastreamer2 @ c48f1a31
Subproject commit 4ed2e518cf79c62fe8df7f23ce99e0fbfe2e799d Subproject commit c48f1a31d850ed9a1b607985d2a250a8ca048547
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment