diff options
-rw-r--r-- | wocky/wocky-porter.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/wocky/wocky-porter.c b/wocky/wocky-porter.c index d83c035..b167b96 100644 --- a/wocky/wocky-porter.c +++ b/wocky/wocky-porter.c @@ -90,6 +90,7 @@ struct _WockyPorterPrivate GCancellable *receive_cancellable; GSimpleAsyncResult *close_result; + gboolean waiting_to_close; gboolean remote_closed; gboolean local_closed; GCancellable *close_cancellable; @@ -750,12 +751,13 @@ send_stanza_cb (GObject *source, } } - if (priv->close_result != NULL && + if (priv->waiting_to_close && g_queue_get_length (priv->sending_queue) == 0) { /* Queue is empty and we are waiting to close the connection. */ DEBUG ("Queue has been flushed. Closing the connection."); send_close (self); + priv->waiting_to_close = FALSE; } g_object_unref (self); @@ -1429,6 +1431,7 @@ wocky_porter_close_async (WockyPorter *self, { DEBUG ("Sending queue is not empty. Flushing it before " "closing the connection."); + priv->waiting_to_close = TRUE; return; } |