From: Timo Sirainen Date: Thu, 13 Jan 2022 14:54:18 +0000 (+0200) Subject: imap: Add client.unhibernated boolean X-Git-Tag: 2.4.0~4476 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ec9618b6441ace70c2d015f29b7ea6b9031019cc;p=thirdparty%2Fdovecot%2Fcore.git imap: Add client.unhibernated boolean --- diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index a36c0e2e92..f9f7a30bfa 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -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; diff --git a/src/imap/imap-client.h b/src/imap/imap-client.h index 507d6366c2..af8af980c7 100644 --- a/src/imap/imap-client.h +++ b/src/imap/imap-client.h @@ -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, diff --git a/src/imap/imap-common.h b/src/imap/imap-common.h index 1609a8b5ba..ec238799d5 100644 --- a/src/imap/imap-common.h +++ b/src/imap/imap-common.h @@ -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 diff --git a/src/imap/imap-master-client.c b/src/imap/imap-master-client.c index 66f7f3d8da..b03e9d9a76 100644 --- a/src/imap/imap-master-client.c +++ b/src/imap/imap-master-client.c @@ -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", diff --git a/src/imap/main.c b/src/imap/main.c index 3221a175ff..e6e112dfd7 100644 --- a/src/imap/main.c +++ b/src/imap/main.c @@ -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); diff --git a/src/imap/test-imap-client-hibernate.c b/src/imap/test-imap-client-hibernate.c index 6136019a84..9b90e1bd9a 100644 --- a/src/imap/test-imap-client-hibernate.c +++ b/src/imap/test-imap-client-hibernate.c @@ -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;