]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Update fuzzy timestamp when adding value
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 21 Jun 2016 12:00:47 +0000 (13:00 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 21 Jun 2016 12:00:47 +0000 (13:00 +0100)
src/fuzzy_storage.c
src/libserver/fuzzy_backend.c
src/libserver/fuzzy_backend.h

index 04498f84d5687ac0bb06debd6335e9d60242be65..31cde97a1c1d69a51e2abc00e7af1fd926c00955 100644 (file)
@@ -394,7 +394,6 @@ rspamd_fuzzy_process_updates_queue (struct rspamd_fuzzy_storage_ctx *ctx,
        gpointer ptr;
        struct rspamd_fuzzy_mirror *m;
        guint nupdates = 0, i;
-       time_t now = time (NULL);
 
        if (ctx->updates_pending &&
                        g_queue_get_length (ctx->updates_pending) > 0 &&
@@ -414,7 +413,7 @@ rspamd_fuzzy_process_updates_queue (struct rspamd_fuzzy_storage_ctx *ctx,
                        }
 
                        if (cmd->cmd == FUZZY_WRITE) {
-                               rspamd_fuzzy_backend_add (ctx->backend, ptr, now);
+                               rspamd_fuzzy_backend_add (ctx->backend, ptr);
                        }
                        else {
                                rspamd_fuzzy_backend_del (ctx->backend, ptr);
index e58e8a546a696570570678b7ec35961650e66e3f..5a22377bbe488d5a484465b002ed716d07acc721 100644 (file)
@@ -135,14 +135,14 @@ static struct rspamd_fuzzy_stmts {
        {
                .idx = RSPAMD_FUZZY_BACKEND_INSERT,
                .sql = "INSERT INTO digests(flag, digest, value, time) VALUES"
-                               "(?1, ?2, ?3, ?4);",
-               .args = "SDII",
+                               "(?1, ?2, ?3, strftime('%s','now'));",
+               .args = "SDI",
                .stmt = NULL,
                .result = SQLITE_DONE
        },
        {
                .idx = RSPAMD_FUZZY_BACKEND_UPDATE,
-               .sql = "UPDATE digests SET value = value + ?1 WHERE "
+               .sql = "UPDATE digests SET value = value + ?1, time = strftime('%s','now') WHERE "
                                "digest==?2;",
                .args = "ID",
                .stmt = NULL,
@@ -150,7 +150,7 @@ static struct rspamd_fuzzy_stmts {
        },
        {
                .idx = RSPAMD_FUZZY_BACKEND_UPDATE_FLAG,
-               .sql = "UPDATE digests SET value = ?1, flag = ?2 WHERE "
+               .sql = "UPDATE digests SET value = ?1, flag = ?2, time = strftime('%s','now') WHERE "
                                "digest==?3;",
                .args = "IID",
                .stmt = NULL,
@@ -662,8 +662,7 @@ rspamd_fuzzy_backend_prepare_update (struct rspamd_fuzzy_backend *backend,
 
 gboolean
 rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend,
-               const struct rspamd_fuzzy_cmd *cmd,
-               time_t timestamp)
+               const struct rspamd_fuzzy_cmd *cmd)
 {
        int rc, i;
        gint64 id, flag;
@@ -740,8 +739,7 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend,
                                RSPAMD_FUZZY_BACKEND_INSERT,
                                (gint) (1U << (cmd->flag - 1)),
                                cmd->digest,
-                               (gint64) cmd->value,
-                               (gint64) timestamp);
+                               (gint64) cmd->value);
 
                if (rc == SQLITE_OK) {
                        if (cmd->shingles_count > 0) {
index 91a613f2a836b9a89ea3e0e9aedd7b7956167db3..6ce50866dda59405c173b4c30642259753b48f05 100644 (file)
@@ -55,10 +55,8 @@ gboolean rspamd_fuzzy_backend_prepare_update (struct rspamd_fuzzy_backend *backe
  * @param cmd
  * @return
  */
-gboolean rspamd_fuzzy_backend_add (
-               struct rspamd_fuzzy_backend *backend,
-               const struct rspamd_fuzzy_cmd *cmd,
-               time_t timestamp);
+gboolean rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend,
+               const struct rspamd_fuzzy_cmd *cmd);
 
 /**
  * Delete digest from the database