]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Avoid logging an error if unhibernation fails due to mailbox being deleted
authorAlexandre Roux <alexandre.roux@open-xchange.com>
Tue, 17 Jun 2025 06:41:06 +0000 (08:41 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 1 Jul 2025 06:57:55 +0000 (06:57 +0000)
src/imap/imap-master-client.c
src/imap/imap-state.c
src/imap/imap-state.h

index cc5cd60f2a35269416771f45d3660e0c9ebf6a2f..952c085f92981bf8a9b5b76ef10e48288ec82173 100644 (file)
@@ -394,6 +394,10 @@ imap_master_client_input_args(struct connection *conn, const char *const *args,
                event_unref(&event);
                client_destroy(imap_client, "Client state initialization failed");
                return -1;
+       case IMAP_STATE_INCONSISTENT:
+               event_unref(&event);
+               client_destroy(imap_client, "Client state inconsistent");
+               return 0;
        case IMAP_STATE_OK:
                break;
        }
index 9790352847a6bad6cad9a7c61ff033c55f56e60a..ccbe50ceca0ae1dac1ba9006ff27651775166cc8 100644 (file)
@@ -574,8 +574,17 @@ import_state_mailbox_open(struct client *client,
                flags |= MAILBOX_FLAG_DROP_RECENT;
        box = mailbox_alloc(ns->list, state->vname, flags);
        if (mailbox_open(box) < 0) {
-               *error_r = t_strdup_printf("Couldn't open mailbox: %s",
-                       mailbox_get_last_internal_error(box, NULL));
+               enum mail_error error;
+               const char *errstr = mailbox_get_last_internal_error(box, &error);
+               const char *full_errstr = t_strdup_printf("Couldn't open mailbox: %s", errstr);
+               if (error == MAIL_ERROR_NOTFOUND) {
+                       e_debug(box->event, "Unhibernation failed to open mailbox: %s", errstr);
+                       client_disconnect_with_error(client,
+                               "IMAP session state is inconsistent, please relogin.");
+                       mailbox_free(&box);
+                       return IMAP_STATE_INCONSISTENT;
+               }
+               *error_r = full_errstr;
                mailbox_free(&box);
                return IMAP_STATE_ERROR;
        }
index 0c5a1cc1250e598231d1bc41345603b8e978dc96..ed690b795931079695cc249428e74946994573ad 100644 (file)
@@ -6,6 +6,7 @@ enum imap_state_result {
        IMAP_STATE_OK, /* Success */
        IMAP_STATE_CORRUPTED, /* Data corruption or invalid state */
        IMAP_STATE_ERROR, /* General error (e.g., permission, resource issues) */
+       IMAP_STATE_INCONSISTENT /* State inconsistency (e.g., mailbox not found) */
 };
 
 /* Export the IMAP client state to the given buffer. Returns 1 if ok,