From: Timo Sirainen Date: Fri, 1 May 2026 17:40:08 +0000 (+0000) Subject: [PATCH 1/5] imap: Extract side-channel ostream creation into helper X-Git-Tag: archive/raspbian/1%2.4.1+dfsg1-6+rpi1+deb13u7^2~13 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=809ab55d766fc58d5383ced157b2eedbd561cc56;p=dovecot.git [PATCH 1/5] imap: Extract side-channel ostream creation into helper Add client_create_side_channel_output() and use it in cmd_compress() in place of the inline channel-creation code. The helper will also be used by the imap state import path to recreate the side channel after unhibernation. No functional change. Gbp-Pq: Name 0001-imap-Extract-side-channel-ostream-creation-into-help.patch --- diff --git a/src/imap/cmd-compress.c b/src/imap/cmd-compress.c index 363d050..18aa988 100644 --- a/src/imap/cmd-compress.c +++ b/src/imap/cmd-compress.c @@ -4,7 +4,6 @@ #include "imap-commands.h" #include "istream.h" #include "ostream.h" -#include "ostream-multiplex.h" #include "iostream-rawlog.h" #include "str.h" #include "strescape.h" @@ -92,13 +91,8 @@ bool cmd_compress(struct client_command_context *cmd) /* Let imap-login process handle the COMPRESS. It's the one that will send the tagged reply to the client. */ client->compress_handler = handler; - if (client->side_channel_output == NULL) { - client->side_channel_output = - o_stream_multiplex_add_channel( - client->multiplex_output, 1); - o_stream_set_no_error_handling( - client->side_channel_output, TRUE); - } + if (client->side_channel_output == NULL) + client_create_side_channel_output(client); string_t *str = t_str_new(64); str_append(str, "compress\t"); str_append_tabescaped(str, handler->name); diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index f8704ba..3de9391 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -678,6 +678,15 @@ void client_send_tagline(struct client_command_context *cmd, const char *data) cmd->client->v.send_tagline(cmd, data); } +void client_create_side_channel_output(struct client *client) +{ + i_assert(client->multiplex_output != NULL); + i_assert(client->side_channel_output == NULL); + client->side_channel_output = + o_stream_multiplex_add_channel(client->multiplex_output, 1); + o_stream_set_no_error_handling(client->side_channel_output, TRUE); +} + static void client_default_send_tagline(struct client_command_context *cmd, const char *data) { diff --git a/src/imap/imap-client.h b/src/imap/imap-client.h index fd1153d..a4f2e4f 100644 --- a/src/imap/imap-client.h +++ b/src/imap/imap-client.h @@ -287,6 +287,11 @@ void client_add_istream_prefix(struct client *client, const unsigned char *data, size_t size); void client_destroy(struct client *client, const char *reason) ATTR_NULL(2); +/* Add the side-channel ostream used to send commands (e.g. dict_reset) back + to the imap-login proxy. Must only be called when multiplex_output is set + and the channel hasn't been created yet. */ +void client_create_side_channel_output(struct client *client); + /* Disconnect client connection */ void client_disconnect(struct client *client, const char *reason); void client_disconnect_with_error(struct client *client,