]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Align rspamd_stat structure
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 26 Feb 2022 12:14:09 +0000 (12:14 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 26 Feb 2022 13:32:26 +0000 (13:32 +0000)
src/controller.c
src/rspamd.c
src/rspamd.h

index 3b524c590f871fe32ebf8e59c344fb799aab2b2d..ca9558046bd239f52b28894244bcf9f5eb8f3b6c 100644 (file)
@@ -720,7 +720,7 @@ rspamd_controller_handle_auth (struct rspamd_http_connection_entry *conn_ent,
        struct rspamd_http_message *msg)
 {
        struct rspamd_controller_session *session = conn_ent->ud;
-       struct rspamd_stat *st;
+       struct rspamd_stat st;
        int64_t uptime;
        gulong data[5];
        ucl_object_t *obj;
@@ -730,13 +730,13 @@ rspamd_controller_handle_auth (struct rspamd_http_connection_entry *conn_ent,
        }
 
        obj = ucl_object_typed_new (UCL_OBJECT);
-       st = session->ctx->srv->stat;
-       data[0] = st->actions_stat[METRIC_ACTION_NOACTION];
-       data[1] = st->actions_stat[METRIC_ACTION_ADD_HEADER] +
-               st->actions_stat[METRIC_ACTION_REWRITE_SUBJECT];
-       data[2] = st->actions_stat[METRIC_ACTION_GREYLIST];
-       data[3] = st->actions_stat[METRIC_ACTION_REJECT];
-       data[4] = st->actions_stat[METRIC_ACTION_SOFT_REJECT];
+       memcpy (&st, session->ctx->srv->stat, sizeof (st));
+       data[0] = st.actions_stat[METRIC_ACTION_NOACTION];
+       data[1] = st.actions_stat[METRIC_ACTION_ADD_HEADER] +
+               st.actions_stat[METRIC_ACTION_REWRITE_SUBJECT];
+       data[2] = st.actions_stat[METRIC_ACTION_GREYLIST];
+       data[3] = st.actions_stat[METRIC_ACTION_REJECT];
+       data[4] = st.actions_stat[METRIC_ACTION_SOFT_REJECT];
 
        /* Get uptime */
        uptime = ev_time () - session->ctx->start_time;
@@ -758,9 +758,9 @@ rspamd_controller_handle_auth (struct rspamd_http_connection_entry *conn_ent,
        ucl_object_insert_key (obj,        ucl_object_fromint (
                        data[4]),                          "soft_reject",   0, false);
        ucl_object_insert_key (obj,        ucl_object_fromint (
-                       st->messages_scanned), "scanned",  0, false);
+                       st.messages_scanned), "scanned",  0, false);
        ucl_object_insert_key (obj,        ucl_object_fromint (
-                       st->messages_learned), "learned",  0, false);
+                       st.messages_learned), "learned",  0, false);
        ucl_object_insert_key (obj, ucl_object_frombool (!session->is_enable),
                        "read_only", 0, false);
        ucl_object_insert_key (obj, ucl_object_fromstring (session->ctx->cfg->checksum),
index 5be64d6f58c4180f5868319dff863c5f956dabdd..04c574b821060f5bdaa061994cf2ec8900ace1cc 100644 (file)
@@ -1348,8 +1348,10 @@ main (gint argc, gchar **argv, gchar **env)
 
        rspamd_main->server_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (),
                        "main", 0);
-       rspamd_main->stat = rspamd_mempool_alloc0_shared (rspamd_main->server_pool,
-                       sizeof (struct rspamd_stat));
+       rspamd_main->stat = rspamd_mempool_alloc0_shared_ (rspamd_main->server_pool,
+                       sizeof (struct rspamd_stat),
+                                       RSPAMD_ALIGNOF(struct rspamd_stat),
+                       G_STRLOC);
        rspamd_main->cfg = rspamd_config_new (RSPAMD_CONFIG_INIT_DEFAULT);
        rspamd_main->spairs = g_hash_table_new_full (rspamd_spair_hash,
                        rspamd_spair_equal, g_free, rspamd_spair_close);
index 2a8f9a442f07b2e917a13394a4d0317ea3a60383..bc2fe0ad77bd9977d51cc706b0da3f1fd926cb57 100644 (file)
@@ -279,15 +279,21 @@ struct rspamd_dns_resolver;
 struct rspamd_task;
 struct rspamd_cryptobox_library_ctx;
 
+#define MAX_AVG_TIME_SLOTS 31
+struct RSPAMD_ALIGNED(64) rspamd_avg_time {
+       guint32 cur_slot;
+       float avg_time[MAX_AVG_TIME_SLOTS];
+};
 /**
  * Server statistics
  */
-struct rspamd_stat {
+struct RSPAMD_ALIGNED(64) rspamd_stat {
        guint messages_scanned;                             /**< total number of messages scanned                               */
        guint actions_stat[METRIC_ACTION_MAX];              /**< statistic for each action                                              */
        guint connections_count;                            /**< total connections count                                                */
        guint control_connections_count;                    /**< connections count to control interface                 */
        guint messages_learned;                             /**< messages learned                                                               */
+       struct rspamd_avg_time avg_time;                    /**< average time stats                                                             */
 };
 
 /**