rspamd_fstring_t *out;
rspamd_token_t *tok;
gchar n0[64], n1[64];
- guint i, l0, l1;
+ guint i, l0, l1, larg0, larg1;
guint64 num;
g_assert (tokens != NULL);
- l0 = strlen (arg0);
- l1 = strlen (arg1);
+ larg0 = strlen (arg0);
+ larg1 = strlen (arg1);
out = rspamd_fstring_sized_new (1024);
- rspamd_printf_fstring (&out, "*%d\r\n"
- "$%d\r\n"
- "%s\r\n"
- "$%d\r\n"
- "%s\r\n",
- learn ? (tokens->len * 2 + 2) : (tokens->len + 2),
- l0, arg0,
- l1, arg1);
+
+ if (!learn) {
+ rspamd_printf_fstring (&out, ""
+ "*%d\r\n"
+ "$%d\r\n"
+ "%s\r\n"
+ "$%d\r\n"
+ "%s\r\n",
+ learn ? (tokens->len * 2 + 2) : (tokens->len + 2),
+ larg0, arg0,
+ larg1, arg1);
+ }
for (i = 0; i < tokens->len; i ++) {
tok = g_ptr_array_index (tokens, i);
memcpy (&num, tok->data, sizeof (num));
- l0 = rspamd_snprintf (n0, sizeof (n0), "%uL", num);
if (learn) {
+ rspamd_printf_fstring (&out, ""
+ "*4\r\n"
+ "$%d\r\n"
+ "%s\r\n"
+ "$%d\r\n"
+ "%s\r\n",
+ larg0, arg0,
+ larg1, arg1);
+
+ l0 = rspamd_snprintf (n0, sizeof (n0), "%uL", num);
if (tok->values[idx] == (guint64)tok->values[idx]) {
l1 = rspamd_snprintf (n1, sizeof (n1), "%uL",
(guint64)tok->values[idx]);
(guint64)tok->values[idx]);
}
- rspamd_printf_fstring (&out, "$%d\r\n%s\r\n"
- "$%d\r\n%s\r\n", l0, n0, l1, n1);
+ rspamd_printf_fstring (&out, ""
+ "$%d\r\n"
+ "%s\r\n"
+ "$%d\r\n"
+ "%s\r\n", l0, n0, l1, n1);
}
else {
- rspamd_printf_fstring (&out, "$%d\r\n%s\r\n", l0, n0);
+ l0 = rspamd_snprintf (n0, sizeof (n0), "%uL", num);
+ rspamd_printf_fstring (&out, ""
+ "$%d\r\n"
+ "%s\r\n", l0, n0);
}
}
rt->id = id;
query = rspamd_redis_tokens_to_query (task, tokens,
- "HMSET", rt->redis_object_expanded, TRUE, id);
+ "HINCRBYFLOAT", rt->redis_object_expanded, TRUE, id);
g_assert (query != NULL);
ret = redisAsyncFormattedCommand (rt->redis, rspamd_redis_learned, rt,