From: Marco Bettini Date: Fri, 24 Feb 2023 09:33:54 +0000 (+0000) Subject: imap: Propagate cmd_tag to notify_progress() X-Git-Tag: 2.4.0~2743 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0d18779cbcf08c554746c42a0a37b9a08cf7b44;p=thirdparty%2Fdovecot%2Fcore.git imap: Propagate cmd_tag to notify_progress() --- diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index ddbff61a69..6d70a8e82d 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -952,7 +952,7 @@ struct client_command_context *client_command_alloc(struct client *client) void client_command_init_finished(struct client_command_context *cmd) { - event_add_str(cmd->event, "cmd_tag", cmd->tag); + event_add_str(cmd->global_event, "cmd_tag", cmd->tag); /* use "unknown" until we checked that the command name is known/valid */ event_add_str(cmd->event, "cmd_name", "unknown"); /* the actual command name received from client - as-is */ diff --git a/src/imap/imap-storage-callbacks.c b/src/imap/imap-storage-callbacks.c index 402204873a..254fa0ba65 100644 --- a/src/imap/imap-storage-callbacks.c +++ b/src/imap/imap-storage-callbacks.c @@ -42,6 +42,14 @@ static void notify_no(struct mailbox *mailbox ATTR_UNUSED, } T_END; } +static const char *find_cmd_tag(struct event *event) +{ + const struct event_field *field = + event_find_field_recursive(event, "cmd_tag"); + return field != NULL && field->value_type == EVENT_FIELD_VALUE_TYPE_STR ? + field->value.str : NULL; +} + const char * imap_storage_callback_line(const struct mail_storage_progress_details *dtl, const char *tag) @@ -112,7 +120,8 @@ int imap_notify_progress(const struct mail_storage_progress_details *dtl, int ret; T_BEGIN { bool corked = o_stream_is_corked(client->output); - const char *line = imap_storage_callback_line(dtl, NULL/*tag*/); + const char *tag = find_cmd_tag(event_get_global()); + const char *line = imap_storage_callback_line(dtl, tag); client_send_line(client, line); ret = o_stream_uncork_flush(client->output);