From: Karl Fleischmann Date: Fri, 7 Mar 2025 09:05:21 +0000 (+0100) Subject: imap-hibernate: Send logout statistics when unhibernating X-Git-Tag: 2.4.1~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=968f524422167a033ec2f705a164d05992da6943;p=thirdparty%2Fdovecot%2Fcore.git imap-hibernate: Send logout statistics when unhibernating --- diff --git a/src/imap-hibernate/imap-client.c b/src/imap-hibernate/imap-client.c index 46261dba3c..5c11dd1dde 100644 --- a/src/imap-hibernate/imap-client.c +++ b/src/imap-hibernate/imap-client.c @@ -212,6 +212,25 @@ imap_client_move_back_send_callback(void *context, struct ostream *output) /* IDLE continues after sending changes */ str_append(str, "\tidle-continue"); } + /* For imap_logout_format statistics: */ + str_printfa(str, + "\tfetch_hdr_count=%u\tfetch_hdr_bytes=%"PRIu64 + "\tfetch_body_count=%u\tfetch_body_bytes=%"PRIu64 + "\tdeleted_count=%u\texpunged_count=%u\ttrashed_count=%u" + "\tautoexpunged_count=%u\tappend_count=%u" + "\tinput_bytes_extra=%"PRIuUOFF_T + "\toutput_bytes_extra=%"PRIuUOFF_T, + client->state.logout_stats.fetch_hdr_count, + client->state.logout_stats.fetch_hdr_bytes, + client->state.logout_stats.fetch_body_count, + client->state.logout_stats.fetch_body_bytes, + client->state.logout_stats.deleted_count, + client->state.logout_stats.expunged_count, + client->state.logout_stats.trashed_count, + client->state.logout_stats.autoexpunged_count, + client->state.logout_stats.append_count, + i_stream_get_absolute_offset(client->input) + client->state.logout_stats.input_bytes_extra, + client->output->offset + client->state.logout_stats.output_bytes_extra); str_append_c(str, '\n'); /* send the fd first */ diff --git a/src/imap-hibernate/imap-client.h b/src/imap-hibernate/imap-client.h index d634780553..f22be018e8 100644 --- a/src/imap-hibernate/imap-client.h +++ b/src/imap-hibernate/imap-client.h @@ -2,6 +2,7 @@ #define IMAP_CLIENT_H #include "net.h" +#include "imap-stats.h" struct imap_client_state { /* required: */ @@ -22,6 +23,8 @@ struct imap_client_state { const unsigned char *state; size_t state_size; + struct imap_logout_stats logout_stats; + guid_128_t anvil_conn_guid; unsigned int imap_idle_notify_interval; bool idle_cmd; diff --git a/src/imap-hibernate/imap-hibernate-client.c b/src/imap-hibernate/imap-hibernate-client.c index e3367b00dc..309fe79bfb 100644 --- a/src/imap-hibernate/imap-hibernate-client.c +++ b/src/imap-hibernate/imap-hibernate-client.c @@ -163,6 +163,72 @@ imap_hibernate_client_parse_input(const char *const *args, pool_t pool, } state_r->state = state_buf->data; state_r->state_size = state_buf->used; + } else if (strcmp(key, "fetch_hdr_count") == 0) { + if (str_to_uint(value, &state_r->logout_stats.fetch_hdr_count) < 0) { + *error_r = t_strdup_printf( + "Invalid fetch_hdr_count value: %s", value); + return -1; + } + } else if (strcmp(key, "fetch_hdr_bytes") == 0) { + if (str_to_uint64(value, &state_r->logout_stats.fetch_hdr_bytes) < 0) { + *error_r = t_strdup_printf( + "Invalid fetch_hdr_bytes value: %s", value); + return -1; + } + } else if (strcmp(key, "fetch_body_count") == 0) { + if (str_to_uint(value, &state_r->logout_stats.fetch_body_count) < 0) { + *error_r = t_strdup_printf( + "Invalid fetch_body_count value: %s", value); + return -1; + } + } else if (strcmp(key, "fetch_body_bytes") == 0) { + if (str_to_uint64(value, &state_r->logout_stats.fetch_body_bytes) < 0) { + *error_r = t_strdup_printf( + "Invalid fetch_body_bytes value: %s", value); + return -1; + } + } else if (strcmp(key, "deleted_count") == 0) { + if (str_to_uint(value, &state_r->logout_stats.deleted_count) < 0) { + *error_r = t_strdup_printf( + "Invalid deleted_count value: %s", value); + return -1; + } + } else if (strcmp(key, "expunged_count") == 0) { + if (str_to_uint(value, &state_r->logout_stats.expunged_count) < 0) { + *error_r = t_strdup_printf( + "Invalid expunged_count value: %s", value); + return -1; + } + } else if (strcmp(key, "trashed_count") == 0) { + if (str_to_uint(value, &state_r->logout_stats.trashed_count) < 0) { + *error_r = t_strdup_printf( + "Invalid trashed_count value: %s", value); + return -1; + } + } else if (strcmp(key, "autoexpunged_count") == 0) { + if (str_to_uint(value, &state_r->logout_stats.autoexpunged_count) < 0) { + *error_r = t_strdup_printf( + "Invalid autoexpunged_count value: %s", value); + return -1; + } + } else if (strcmp(key, "append_count") == 0) { + if (str_to_uint(value, &state_r->logout_stats.append_count) < 0) { + *error_r = t_strdup_printf( + "Invalid append_count value: %s", value); + return -1; + } + } else if (strcmp(key, "input_bytes_extra") == 0) { + if (str_to_uoff(value, &state_r->logout_stats.input_bytes_extra) < 0) { + *error_r = t_strdup_printf( + "Invalid input_bytes_extra value: %s", value); + return -1; + } + } else if (strcmp(key, "output_bytes_extra") == 0) { + if (str_to_uoff(value, &state_r->logout_stats.output_bytes_extra) < 0) { + *error_r = t_strdup_printf( + "Invalid output_bytes_extra value: %s", value); + return -1; + } } } if (state_r->tag == NULL) {