]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-hibernate: Send logout statistics when unhibernating
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Fri, 7 Mar 2025 09:05:21 +0000 (10:05 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Mar 2025 06:40:04 +0000 (06:40 +0000)
src/imap-hibernate/imap-client.c
src/imap-hibernate/imap-client.h
src/imap-hibernate/imap-hibernate-client.c

index 46261dba3cb5a00c1b6bee8f2b573ddfb8cd4cfd..5c11dd1ddedf1fa20633f8d9d49b86d7a88a68c2 100644 (file)
@@ -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 */
index d6347805533418fffc12061eca77b97f6f0084f4..f22be018e8a121d471d6766d70a23796cb0467f1 100644 (file)
@@ -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;
index e3367b00dc00022cfe1a054470a4ca412a001482..309fe79bfb39f15ab2b472c51bd2898522a47711 100644 (file)
@@ -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) {