commit 811f3d7: eliminate smembers: fix again
resec
resec0109 at gmail.com
Thu Jan 16 12:35:09 UTC 2020
Author: resec
Date: 2019-11-19 11:30:21 +0000
URL: https://github.com/rspamd/rspamd/commit/811f3d7c675d12860231d269bc728047f9ba80ff
eliminate smembers: fix again
---
src/libstat/backends/redis_backend.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index eab238532..d4ac6a30e 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -846,9 +846,10 @@ rspamd_redis_stat_keys (redisAsyncContext *c, gpointer r, gpointer priv)
{
struct rspamd_redis_stat_elt *redis_elt = (struct rspamd_redis_stat_elt *)priv;
struct rspamd_redis_stat_cbdata *cbdata;
- redisReply *reply = r, *more, *elts, *elt;
+ redisReply *reply = r, *more_elt, *elts, *elt;
gchar **pk, *k;
guint i, processed = 0;
+ gboolean more = false;
cbdata = redis_elt->cbdata;
@@ -860,9 +861,13 @@ rspamd_redis_stat_keys (redisAsyncContext *c, gpointer r, gpointer priv)
if (c->err == 0 && r != NULL) {
if (reply->type == REDIS_REPLY_ARRAY) {
- more = reply->element[0];
+ more_elt = reply->element[0];
elts = reply->element[1];
+ if (more_elt != NULL && more_elt->str != NULL && strcmp (more_elt->str, "0") != 0) {
+ more = true;
+ }
+
g_ptr_array_set_size (cbdata->cur_keys, elts->elements);
for (i = 0; i < elts->elements; i ++) {
@@ -915,7 +920,7 @@ rspamd_redis_stat_keys (redisAsyncContext *c, gpointer r, gpointer priv)
}
}
- if (more != NULL && more->integer) {
+ if (more) {
/* Cleanup the cbdata->cur_keys and re-allowcate */
for (i = 0; i < cbdata->cur_keys->len; i ++) {
k = g_ptr_array_index (cbdata->cur_keys, i);
@@ -928,8 +933,10 @@ rspamd_redis_stat_keys (redisAsyncContext *c, gpointer r, gpointer priv)
/* Get more keys */
redisAsyncCommand (cbdata->redis, rspamd_redis_stat_keys, redis_elt,
- "SSCAN %s_keys %d COUNT 1000",
- cbdata->elt->ctx->stcf->symbol, more->integer);
+ "SSCAN %s_keys %s COUNT 1000",
+ cbdata->elt->ctx->stcf->symbol, more_elt->str);
+
+ cbdata->inflight += 1;
}
else {
/* Set up the required keys */
More information about the Commits
mailing list