From f7745f50bd42741589eb42fe8371f2bf92d57be1 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Thu, 16 Mar 2023 12:51:56 +0100 Subject: [PATCH] sip-origin: Keep sofia running to allow unregistering on dispose sofia-sip needs to keep iterating its' main loop in order to unregister as well as process the response from the server. Closes: #554 --- plugins/provider/sip/calls-sip-origin.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/plugins/provider/sip/calls-sip-origin.c b/plugins/provider/sip/calls-sip-origin.c index 6e0e140..e54505c 100644 --- a/plugins/provider/sip/calls-sip-origin.c +++ b/plugins/provider/sip/calls-sip-origin.c @@ -22,6 +22,9 @@ * */ +#define WAIT_FOR_OFFLINE_MS 100 +#define WAIT_FOR_OFFLINE_RETRIES 5 + #define G_LOG_DOMAIN "CallsSipOrigin" @@ -1505,6 +1508,21 @@ static void calls_sip_origin_dispose (GObject *object) { CallsSipOrigin *self = CALLS_SIP_ORIGIN (object); + gboolean su_step_timeout = FALSE; + guint i = 0; + + if (!self->use_direct_connection && self->state == CALLS_ACCOUNT_STATE_ONLINE) { + go_online (CALLS_ACCOUNT (self), FALSE); + + while (self->state != CALLS_ACCOUNT_STATE_OFFLINE && !su_step_timeout) { + su_root_step (self->ctx->root, WAIT_FOR_OFFLINE_MS); + + if (i++ > WAIT_FOR_OFFLINE_RETRIES) + su_step_timeout = TRUE; + } + } + + deinit_sip_account (self); g_clear_pointer (&self->id, g_free); g_clear_pointer (&self->own_ip, g_free); @@ -1514,11 +1532,6 @@ calls_sip_origin_dispose (GObject *object) g_clear_pointer (&self->user, g_free); g_clear_pointer (&self->password, g_free); - if (!self->use_direct_connection && self->state == CALLS_ACCOUNT_STATE_ONLINE) - go_online (CALLS_ACCOUNT (self), FALSE); - - deinit_sip_account (self); - G_OBJECT_CLASS (calls_sip_origin_parent_class)->dispose (object); }