]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: client_create*() - Change unhibernated boolean to enum flags
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 8 Apr 2024 21:06:34 +0000 (00:06 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 18 Jun 2024 08:31:38 +0000 (08:31 +0000)
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 8d67996514100f09153ef606058e96b5e683a166..2d4b9a69995cbcaebbf00ac2a18bfd9d55712c2f 100644 (file)
@@ -90,7 +90,8 @@ static bool user_has_special_use_mailboxes(struct mail_user *user)
        return mail_set->parsed_have_special_use_mailboxes;
 }
 
-struct client *client_create(int fd_in, int fd_out, bool unhibernated,
+struct client *client_create(int fd_in, int fd_out,
+                            enum client_create_flags flags,
                             struct event *event, struct mail_user *user,
                             const struct imap_settings *set,
                             const struct smtp_submit_settings *smtp_set)
@@ -109,7 +110,7 @@ struct client *client_create(int fd_in, int fd_out, bool unhibernated,
        client->v = imap_client_vfuncs;
        client->event = event;
        event_ref(client->event);
-       client->unhibernated = unhibernated;
+       client->unhibernated = (flags & CLIENT_CREATE_FLAG_UNHIBERNATED) != 0;
        client->set = set;
        client->smtp_set = smtp_set;
        client->fd_in = fd_in;
index f8a54e643eeda0d22b8fed2e85eca7964526eedd..548e38fd4a2985d9b794d929ab2c12c151058f1d 100644 (file)
@@ -18,6 +18,10 @@ struct imap_parser;
 struct imap_arg;
 struct imap_urlauth_context;
 
+enum client_create_flags {
+       CLIENT_CREATE_FLAG_UNHIBERNATED = BIT(0),
+};
+
 struct mailbox_keywords {
        /* All keyword names. The array itself exists in mail_index.
           Keywords are currently only appended, they're never removed. */
@@ -270,7 +274,8 @@ 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, bool unhibernated,
+struct client *client_create(int fd_in, int fd_out,
+                            enum client_create_flags flags,
                             struct event *event, struct mail_user *user,
                             const struct imap_settings *set,
                             const struct smtp_submit_settings *smtp_set);
index ec238799d5b88e8490f0c9aa11b611448d39e3e9..438616ded2e03b8b5df4058fbdf627c53f45b855 100644 (file)
@@ -34,7 +34,8 @@ 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, bool unhibernated,
+                            int fd_in, int fd_out,
+                            enum client_create_flags flags,
                             struct client **client_r, const char **error_r);
 
 #endif
index 1784afeabf77e090b706eb1cf074059be9d11f73..90df453230b63a710f083ab7965750778e342c31 100644 (file)
@@ -242,7 +242,8 @@ 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,
-                                      TRUE, &imap_client, &error);
+                                      CLIENT_CREATE_FLAG_UNHIBERNATED,
+                                      &imap_client, &error);
        if (ret < 0) {
                e_error(conn->event,
                        "imap-master(%s): Failed to create client: %s",
index 1f3141050d5b4b7deca71857b81f4a958ed4a00d..f9d05472b4beb64fd9aab147fd5f58655de53797 100644 (file)
@@ -244,7 +244,8 @@ 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, bool unhibernated,
+                            int fd_in, int fd_out,
+                            enum client_create_flags flags,
                             struct client **client_r, const char **error_r)
 {
        struct mail_storage_service_input service_input;
@@ -294,7 +295,7 @@ int client_create_from_input(const struct mail_storage_service_input *input,
        if (imap_set->verbose_proctitle)
                verbose_proctitle = TRUE;
 
-       client = client_create(fd_in, fd_out, unhibernated,
+       client = client_create(fd_in, fd_out, flags,
                               event, mail_user, imap_set, smtp_set);
        client->userdb_fields = input->userdb_fields == NULL ? NULL :
                p_strarray_dup(client->pool, input->userdb_fields);
@@ -323,7 +324,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,
-                                    FALSE, &client, &error) < 0)
+                                    0, &client, &error) < 0)
                i_fatal("%s", error);
 
        input_base64 = getenv("CLIENT_INPUT");
@@ -380,7 +381,7 @@ login_request_finished(const struct login_server_request *request,
                                        &imap_request);
 
        if (client_create_from_input(&input, request->fd, request->fd,
-                                    FALSE, &client, &error) < 0) {
+                                    0, &client, &error) < 0) {
                int fd = request->fd;
                struct ostream *output =
                        o_stream_create_fd_autoclose(&fd, IO_BLOCK_SIZE);
index 20411b8654bcc6b0306a2d3db974a0a4d19200f7..f6f641ae463292c313e738e575a4bd8dd0030c97 100644 (file)
@@ -40,7 +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,
+                            enum client_create_flags flags ATTR_UNUSED,
                             struct client **client_r ATTR_UNUSED,
                             const char **error_r ATTR_UNUSED) { return -1; }
 
@@ -173,7 +173,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, FALSE, event, mail_user,
+       client = client_create(client_fd, client_fd, 0, event, mail_user,
                               imap_setting_parser_info.defaults, &smtp_set);
        ctx.client = client;