summaryrefslogtreecommitdiff
path: root/src/redis-check-rdb.c
diff options
context:
space:
mode:
authorchenyang8094 <chenyang8094@users.noreply.github.com>2021-06-16 14:45:49 +0800
committerGitHub <noreply@github.com>2021-06-16 09:45:49 +0300
commite0cd3ad0de0bf2fe6ea0227e5ad7a0a489688b33 (patch)
tree799442b67bc21b1f4e70ebedd14ddde586d1d183 /src/redis-check-rdb.c
parent7f342020dcbdf9abe754d6b666efdeded7063870 (diff)
downloadredis-e0cd3ad0de0bf2fe6ea0227e5ad7a0a489688b33.tar.gz
Enhance mem_usage/free_effort/unlink/copy callbacks and add GetDbFromIO api. (#8999)
Create new module type enhanced callbacks: mem_usage2, free_effort2, unlink2, copy2. These will be given a context point from which the module can obtain the key name and database id. In addition the digest and defrag context can now be used to obtain the key name and database id.
Diffstat (limited to 'src/redis-check-rdb.c')
-rw-r--r--src/redis-check-rdb.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/redis-check-rdb.c b/src/redis-check-rdb.c
index 8f57fa4d4..b2cc6a5b4 100644
--- a/src/redis-check-rdb.c
+++ b/src/redis-check-rdb.c
@@ -184,6 +184,7 @@ void rdbCheckSetupSignals(void) {
* otherwise the already open file 'fp' is checked. */
int redis_check_rdb(char *rdbfilename, FILE *fp) {
uint64_t dbid;
+ int selected_dbid = -1;
int type, rdbver;
char buf[1024];
long long expiretime, now = mstime();
@@ -251,6 +252,7 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) {
if ((dbid = rdbLoadLen(&rdb,NULL)) == RDB_LENERR)
goto eoferr;
rdbCheckInfo("Selecting DB ID %llu", (unsigned long long)dbid);
+ selected_dbid = dbid;
continue; /* Read type again. */
} else if (type == RDB_OPCODE_RESIZEDB) {
/* RESIZEDB: Hint about the size of the keys in the currently
@@ -308,7 +310,7 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) {
rdbstate.keys++;
/* Read value */
rdbstate.doing = RDB_CHECK_DOING_READ_OBJECT_VALUE;
- if ((val = rdbLoadObject(type,&rdb,key->ptr)) == NULL) goto eoferr;
+ if ((val = rdbLoadObject(type,&rdb,key->ptr,selected_dbid)) == NULL) goto eoferr;
/* Check if the key already expired. */
if (expiretime != -1 && expiretime < now)
rdbstate.already_expired++;