Skip to content

Commit

Permalink
Remove sleep on error in redis_find() and redis_flush_all().
Browse files Browse the repository at this point in the history
  • Loading branch information
kroosec authored and jjnicola committed May 13, 2019
1 parent 6bf2732 commit e10ce02
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions util/kb.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <stdio.h>
#include <stdlib.h> /* for atoi */
#include <string.h> /* for strlen, strerror, strncpy, memset */
#include <unistd.h> /* for sleep */

#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "lib kb"
Expand All @@ -50,12 +49,6 @@
*/
#define GLOBAL_DBINDEX_NAME "GVM.__GlobalDBIndex"

/**
* @brief Number of seconds to wait for between two attempts to acquire a KB
* namespace.
*/
#define KB_RETRY_DELAY 60

static const struct kb_operations KBRedisOperations;

/**
Expand Down Expand Up @@ -490,7 +483,7 @@ redis_find (const char *kb_path, const char *key)
rep = redisCommand (kbr->rctx, "SELECT %u", i);
if (rep == NULL || rep->type != REDIS_REPLY_STATUS)
{
sleep (KB_RETRY_DELAY);
redisFree (kbr->rctx);
kbr->rctx = NULL;
}
else
Expand All @@ -505,8 +498,8 @@ redis_find (const char *kb_path, const char *key)
return (kb_t) kbr;
}
}
redisFree (kbr->rctx);
}
redisFree (kbr->rctx);
i++;
}
while (i < kbr->max_db);
Expand Down Expand Up @@ -1406,7 +1399,6 @@ redis_flush_all (kb_t kb, const char *except)
if (rep == NULL || rep->type != REDIS_REPLY_STATUS)
{
freeReplyObject (rep);
sleep (KB_RETRY_DELAY);
redisFree (kbr->rctx);
kbr->rctx = NULL;
}
Expand Down

0 comments on commit e10ce02

Please sign in to comment.