]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Add client.unhibernated boolean
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 13 Jan 2022 14:54:18 +0000 (16:54 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 8 Feb 2022 09:48:24 +0000 (10:48 +0100)
src/imap/imap-client.c
src/imap/imap-client.h
src/imap/imap-common.h
src/imap/imap-master-client.c
src/imap/main.c
src/imap/test-imap-client-hibernate.c

index a36c0e2e92c6ca4f1540c5171d1b78406f9d0bbb..f9f7a30bfa602ffbfd14eba7ac7b7ce02001954c 100644 (file)
@@ -110,7 +110,7 @@ static bool user_has_special_use_mailboxes(struct mail_user *user)
        return FALSE;
 }
 
-struct client *client_create(int fd_in, int fd_out,
+struct client *client_create(int fd_in, int fd_out, bool unhibernated,
                             struct event *event, struct mail_user *user,
                             struct mail_storage_service_user *service_user,
                             const struct imap_settings *set,
@@ -130,6 +130,7 @@ struct client *client_create(int fd_in, int fd_out,
        client->v = imap_client_vfuncs;
        client->event = event;
        event_ref(client->event);
+       client->unhibernated = unhibernated;
        client->set = set;
        client->smtp_set = smtp_set;
        client->service_user = service_user;
index 507d6366c23dd5e7b0f7bb689ccde5807e6ff75a..af8af980c7db92e4763c8941370262e6f00cf011 100644 (file)
@@ -230,6 +230,7 @@ struct client {
        bool logged_out:1;
        bool disconnected:1;
        bool hibernated:1;
+       bool unhibernated:1; /* client was created by unhibernation */
        bool destroyed:1;
        bool handling_input:1;
        bool syncing:1;
@@ -266,7 +267,7 @@ extern unsigned int imap_feature_qresync;
 
 /* Create new client with specified input/output handles. socket specifies
    if the handle is a socket. */
-struct client *client_create(int fd_in, int fd_out,
+struct client *client_create(int fd_in, int fd_out, bool unhibernated,
                             struct event *event, struct mail_user *user,
                             struct mail_storage_service_user *service_user,
                             const struct imap_settings *set,
index 1609a8b5bab6f53b28a59ececd9cefd194c1d261..ec238799d5b88e8490f0c9aa11b611448d39e3e9 100644 (file)
@@ -34,7 +34,7 @@ void imap_refresh_proctitle(void);
 void imap_refresh_proctitle_delayed(void);
 
 int client_create_from_input(const struct mail_storage_service_input *input,
-                            int fd_in, int fd_out, struct client **client_r,
-                            const char **error_r);
+                            int fd_in, int fd_out, bool unhibernated,
+                            struct client **client_r, const char **error_r);
 
 #endif
index 66f7f3d8da220c0efe3e62f62be6b07ca1697122..b03e9d9a761480be19f3aba9a49c9ffcab0fc6f1 100644 (file)
@@ -240,7 +240,7 @@ imap_master_client_input_args(struct connection *conn, const char *const *args,
        /* NOTE: before client_create_from_input() on failures we need to close
           fd_client, but afterward it gets closed by client_destroy() */
        ret = client_create_from_input(&input, fd_client, fd_client,
-                                      &imap_client, &error);
+                                      TRUE, &imap_client, &error);
        if (ret < 0) {
                e_error(conn->event,
                        "imap-master(%s): Failed to create client: %s",
index 3221a175ff4fc8e38b4ca522d2515add87f22bd4..e6e112dfd7520e9cd81336a5bda5e03ea1b23c2e 100644 (file)
@@ -236,7 +236,7 @@ client_add_input_finalize(struct client *client)
 }
 
 int client_create_from_input(const struct mail_storage_service_input *input,
-                            int fd_in, int fd_out,
+                            int fd_in, int fd_out, bool unhibernated,
                             struct client **client_r, const char **error_r)
 {
        struct mail_storage_service_input service_input;
@@ -294,7 +294,7 @@ int client_create_from_input(const struct mail_storage_service_input *input,
                return -1;
        }
 
-       client = client_create(fd_in, fd_out,
+       client = client_create(fd_in, fd_out, unhibernated,
                               event, mail_user, user, imap_set, smtp_set);
        client->userdb_fields = input->userdb_fields == NULL ? NULL :
                p_strarray_dup(client->pool, input->userdb_fields);
@@ -323,7 +323,7 @@ static void main_stdio_run(const char *username)
                (void)net_addr2ip(value, &input.local_ip);
 
        if (client_create_from_input(&input, STDIN_FILENO, STDOUT_FILENO,
-                                    &client, &error) < 0)
+                                    FALSE, &client, &error) < 0)
                i_fatal("%s", error);
 
        input_base64 = getenv("CLIENT_INPUT");
@@ -381,7 +381,7 @@ login_client_connected(const struct master_login_client *login_client,
                                        &request);
 
        if (client_create_from_input(&input, login_client->fd, login_client->fd,
-                                    &client, &error) < 0) {
+                                    FALSE, &client, &error) < 0) {
                int fd = login_client->fd;
                struct ostream *output =
                        o_stream_create_fd_autoclose(&fd, IO_BLOCK_SIZE);
index 6136019a84271e6a04f1e1cd15132fac75deea7f..9b90e1bd9a00ac55ec0724d8a2f6a78291e19758 100644 (file)
@@ -40,6 +40,7 @@ void imap_refresh_proctitle(void) { }
 void imap_refresh_proctitle_delayed(void) { }
 int client_create_from_input(const struct mail_storage_service_input *input ATTR_UNUSED,
                             int fd_in ATTR_UNUSED, int fd_out ATTR_UNUSED,
+                            bool unhibernated ATTR_UNUSED,
                             struct client **client_r ATTR_UNUSED,
                             const char **error_r ATTR_UNUSED) { return -1; }
 
@@ -173,7 +174,7 @@ static void test_imap_client_hibernate(void)
 
        struct event *event = event_create(NULL);
        int client_fd = dup(dev_null_fd);
-       client = client_create(client_fd, client_fd, event,
+       client = client_create(client_fd, client_fd, FALSE, event,
                               mail_user, service_user,
                               imap_setting_parser_info.defaults, &smtp_set);
        ctx.client = client;