From: Timo Sirainen Date: Mon, 8 Apr 2024 21:06:34 +0000 (+0300) Subject: imap: client_create*() - Change unhibernated boolean to enum flags X-Git-Tag: 2.4.0~1580 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fe1f395fb6bb278f0d0a5fa0df1820d97b259acb;p=thirdparty%2Fdovecot%2Fcore.git imap: client_create*() - Change unhibernated boolean to enum flags --- diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index 8d67996514..2d4b9a6999 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -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; diff --git a/src/imap/imap-client.h b/src/imap/imap-client.h index f8a54e643e..548e38fd4a 100644 --- a/src/imap/imap-client.h +++ b/src/imap/imap-client.h @@ -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); diff --git a/src/imap/imap-common.h b/src/imap/imap-common.h index ec238799d5..438616ded2 100644 --- a/src/imap/imap-common.h +++ b/src/imap/imap-common.h @@ -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 diff --git a/src/imap/imap-master-client.c b/src/imap/imap-master-client.c index 1784afeabf..90df453230 100644 --- a/src/imap/imap-master-client.c +++ b/src/imap/imap-master-client.c @@ -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", diff --git a/src/imap/main.c b/src/imap/main.c index 1f3141050d..f9d05472b4 100644 --- a/src/imap/main.c +++ b/src/imap/main.c @@ -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); diff --git a/src/imap/test-imap-client-hibernate.c b/src/imap/test-imap-client-hibernate.c index 20411b8654..f6f641ae46 100644 --- a/src/imap/test-imap-client-hibernate.c +++ b/src/imap/test-imap-client-hibernate.c @@ -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;