}
static void
-rspamd_fuzzy_updates_cb (gboolean success, void *ud)
+rspamd_fuzzy_updates_cb (gboolean success,
+ guint nadded,
+ guint ndeleted,
+ guint nextended,
+ guint nignored,
+ void *ud)
{
struct rspamd_updates_cbdata *cbdata = ud;
struct rspamd_fuzzy_mirror *m;
}
}
- msg_info ("successfully updated fuzzy storage: %d updates processed",
- ctx->updates_pending->len);
+ msg_info ("successfully updated fuzzy storage: %d updates in queue; "
+ "%d added, %d deleted, %d extended, %d duplicates",
+ ctx->updates_pending->len,
+ nadded, ndeleted, nextended, nignored);
/* Clear updates */
ctx->updates_pending->len = 0;
rspamd_fuzzy_backend_version (ctx->backend, source,
struct fuzzy_peer_cmd *io_cmd;
struct rspamd_fuzzy_cmd *cmd;
gpointer ptr;
- guint nupdates = 0;
+ guint nupdates = 0, nadded = 0, ndeleted = 0, nextended = 0, nignored = 0;
if (rspamd_fuzzy_backend_sqlite_prepare_update (sq, src)) {
for (i = 0; i < updates->len; i ++) {
if (cmd->cmd == FUZZY_WRITE) {
rspamd_fuzzy_backend_sqlite_add (sq, ptr);
+ nadded ++;
nupdates ++;
}
else if (cmd->cmd == FUZZY_DEL) {
rspamd_fuzzy_backend_sqlite_del (sq, ptr);
+ ndeleted ++;
nupdates ++;
}
else {
- /* Do nothing for expire, this backend should no longer be used */
+ if (cmd->cmd == FUZZY_REFRESH) {
+ nextended ++;
+ }
+ else {
+ nignored ++;
+ }
}
}
}
if (cb) {
- cb (success, ud);
+ cb (success, nadded, ndeleted, nextended, nignored, ud);
}
}
bk->subr->update (bk, updates, src, cb, ud, bk->subr_ud);
}
else if (cb) {
- cb (TRUE, ud);
+ cb (TRUE, 0, 0, 0, 0, ud);
}
}
ref_entry_t ref;
};
+enum rspamd_fuzzy_redis_command {
+ RSPAMD_FUZZY_REDIS_COMMAND_COUNT,
+ RSPAMD_FUZZY_REDIS_COMMAND_VERSION,
+ RSPAMD_FUZZY_REDIS_COMMAND_UPDATES,
+ RSPAMD_FUZZY_REDIS_COMMAND_CHECK
+};
+
struct rspamd_fuzzy_redis_session {
struct rspamd_fuzzy_backend_redis *backend;
redisAsyncContext *ctx;
float prob;
gboolean shingles_checked;
- enum {
- RSPAMD_FUZZY_REDIS_COMMAND_COUNT,
- RSPAMD_FUZZY_REDIS_COMMAND_VERSION,
- RSPAMD_FUZZY_REDIS_COMMAND_UPDATES,
- RSPAMD_FUZZY_REDIS_COMMAND_CHECK
- } command;
+ enum rspamd_fuzzy_redis_command command;
guint nargs;
+ guint nadded;
+ guint ndeleted;
+ guint nextended;
+ guint nignored;
+
union {
rspamd_fuzzy_check_cb cb_check;
rspamd_fuzzy_update_cb cb_update;
if (reply->type == REDIS_REPLY_ARRAY) {
/* TODO: check all replies somehow */
if (session->callback.cb_update) {
- session->callback.cb_update (TRUE, session->cbdata);
+ session->callback.cb_update (TRUE,
+ session->nadded,
+ session->ndeleted,
+ session->nextended,
+ session->nignored,
+ session->cbdata);
}
}
else {
if (session->callback.cb_update) {
- session->callback.cb_update (FALSE, session->cbdata);
+ session->callback.cb_update (FALSE, 0, 0, 0, 0, session->cbdata);
}
}
}
else {
if (session->callback.cb_update) {
- session->callback.cb_update (FALSE, session->cbdata);
+ session->callback.cb_update (FALSE, 0, 0, 0, 0, session->cbdata);
}
if (c->errstr) {
if (cmd->cmd == FUZZY_WRITE) {
ncommands += 5;
nargs += 17;
+ session->nadded ++;
if (io_cmd->is_shingle) {
ncommands += RSPAMD_SHINGLE_SIZE;
else if (cmd->cmd == FUZZY_DEL) {
ncommands += 2;
nargs += 4;
+ session->ndeleted ++;
if (io_cmd->is_shingle) {
ncommands += RSPAMD_SHINGLE_SIZE;
else if (cmd->cmd == FUZZY_REFRESH) {
ncommands += 1;
nargs += 3;
+ session->nextended ++;
if (io_cmd->is_shingle) {
ncommands += RSPAMD_SHINGLE_SIZE;
nargs += RSPAMD_SHINGLE_SIZE * 3;
}
}
+ else {
+ session->nignored ++;
+ }
}
/* Now we need to create a new request */
rspamd_fuzzy_redis_session_dtor (session, TRUE);
if (cb) {
- cb (FALSE, ud);
+ cb (FALSE, 0, 0, 0, 0, ud);
}
}
else {
session->argv_lens) != REDIS_OK) {
if (cb) {
- cb (FALSE, ud);
+ cb (FALSE, 0, 0, 0, 0, ud);
}
rspamd_fuzzy_redis_session_dtor (session, TRUE);
if (!rspamd_fuzzy_update_append_command (bk, session, io_cmd,
&cur_shift)) {
if (cb) {
- cb (FALSE, ud);
+ cb (FALSE, 0, 0, 0, 0, ud);
}
rspamd_fuzzy_redis_session_dtor (session, TRUE);
&session->argv_lens[cur_shift - 2]) != REDIS_OK) {
if (cb) {
- cb (FALSE, ud);
+ cb (FALSE, 0, 0, 0, 0, ud);
}
rspamd_fuzzy_redis_session_dtor (session, TRUE);
&session->argv_lens[cur_shift]) != REDIS_OK) {
if (cb) {
- cb (FALSE, ud);
+ cb (FALSE, 0, 0, 0, 0, ud);
}
rspamd_fuzzy_redis_session_dtor (session, TRUE);