Browse Source

MT#55283 shortcut for empty Redis restores

Don't launch a bunch of threads to do nothing if we know that there's
nothing to restore.

Change-Id: I681af675f38cc42c2c48c6d8ec4da5421b7c47ba
pull/1611/head
Richard Fuchs 3 years ago
parent
commit
18595419b4
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      daemon/redis.c

+ 5
- 0
daemon/redis.c View File

@ -2187,6 +2187,9 @@ int redis_restore(struct redis *r, bool foreign, int db) {
goto err; goto err;
} }
if (calls->elements == 0)
goto out;
mutex_init(&ctx.r_m); mutex_init(&ctx.r_m);
g_queue_init(&ctx.r_q); g_queue_init(&ctx.r_q);
ctx.foreign = foreign; ctx.foreign = foreign;
@ -2209,6 +2212,8 @@ int redis_restore(struct redis *r, bool foreign, int db) {
g_thread_pool_free(gtp, FALSE, TRUE); g_thread_pool_free(gtp, FALSE, TRUE);
while ((r = g_queue_pop_head(&ctx.r_q))) while ((r = g_queue_pop_head(&ctx.r_q)))
redis_close(r); redis_close(r);
out:
ret = 0; ret = 0;
freeReplyObject(calls); freeReplyObject(calls);


Loading…
Cancel
Save