From: Timo Sirainen Date: Wed, 4 Sep 2019 10:22:16 +0000 (+0300) Subject: imap-hibernate: Fix crashes caused by unhibernation queue handling X-Git-Tag: 2.3.10~305 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90ae767c59631c72d6b4bf4678a06421ec3d4dfc;p=thirdparty%2Fdovecot%2Fcore.git imap-hibernate: Fix crashes caused by unhibernation queue handling These only started happening after the following commit that fixes unhibernation to actually start happening. --- diff --git a/src/imap-hibernate/imap-client.c b/src/imap-hibernate/imap-client.c index 5adcb4943d..64348e8b5c 100644 --- a/src/imap-hibernate/imap-client.c +++ b/src/imap-hibernate/imap-client.c @@ -247,8 +247,10 @@ static void imap_client_move_back(struct imap_client *client) /* imap-master socket is busy. retry in a while. */ if (client->move_back_start == 0) client->move_back_start = ioloop_time; - client->unhibernate_queued = TRUE; - priorityq_add(unhibernate_queue, &client->item); + if (!client->unhibernate_queued) { + client->unhibernate_queued = TRUE; + priorityq_add(unhibernate_queue, &client->item); + } if (to_unhibernate == NULL) { to_unhibernate = timeout_add_short(IMAP_UNHIBERNATE_RETRY_MSECS, imap_clients_unhibernate, NULL); @@ -583,8 +585,10 @@ static void imap_client_stop(struct imap_client *client) { struct imap_client_notify *notify; - if (client->unhibernate_queued) + if (client->unhibernate_queued) { priorityq_remove(unhibernate_queue, &client->item); + client->unhibernate_queued = FALSE; + } io_remove(&client->io); timeout_remove(&client->to_keepalive); @@ -693,7 +697,7 @@ static void imap_clients_unhibernate(void *context ATTR_UNUSED) { struct priorityq_item *item; - while ((item = priorityq_pop(unhibernate_queue)) != NULL) { + while ((item = priorityq_peek(unhibernate_queue)) != NULL) { struct imap_client *client = (struct imap_client *)item; if (!imap_client_try_move_back(client))