Fix crash during hook module test

Former-commit-id: 628d168049d00526169d13e31f540820aed1437c
This commit is contained in:
John Sully 2020-05-10 21:57:16 -04:00
parent f76a52b957
commit 03b811b13c
2 changed files with 8 additions and 4 deletions

View File

@ -1775,15 +1775,15 @@ int modulePopulateReplicationInfoStructure(void *ri, int structver) {
memset(ri1,0,sizeof(*ri1)); memset(ri1,0,sizeof(*ri1));
ri1->version = structver; ri1->version = structver;
ri1->master = listLength(g_pserver->masters) == 0; ri1->master = listLength(g_pserver->masters) == 0;
if (ri1->master) if (!ri1->master)
{ {
redisMaster *mi = (redisMaster*)listFirst(g_pserver->masters); redisMaster *mi = (redisMaster*)listNodeValue(listFirst(g_pserver->masters));
ri1->masterhost = (char*)(mi->masterhost? mi->masterhost: ""); ri1->masterhost = (char*)(mi->masterhost? mi->masterhost: "");
ri1->masterport = mi->masterport; ri1->masterport = mi->masterport;
} }
else else
{ {
ri1->masterhost = nullptr; ri1->masterhost = "";
ri1->masterport = -1; ri1->masterport = -1;
} }
ri1->repl1_offset = g_pserver->master_repl_offset; ri1->repl1_offset = g_pserver->master_repl_offset;
@ -7765,8 +7765,12 @@ int RM_GetLFU(RedisModuleKey *key, long long *lfu_freq) {
*lfu_freq = -1; *lfu_freq = -1;
if (!key->value) if (!key->value)
return REDISMODULE_ERR; return REDISMODULE_ERR;
serverLog(LL_WARNING, "MAXMEMORY_POLICY: %X", g_pserver->maxmemory_policy);
if (g_pserver->maxmemory_policy & MAXMEMORY_FLAG_LFU) if (g_pserver->maxmemory_policy & MAXMEMORY_FLAG_LFU)
{
*lfu_freq = LFUDecrAndReturn(key->value); *lfu_freq = LFUDecrAndReturn(key->value);
serverLog(LL_WARNING, "lfu_freq: %lld", lfu_freq);
}
return REDISMODULE_OK; return REDISMODULE_OK;
} }

View File

@ -324,7 +324,7 @@ typedef struct RedisModuleReplicationInfo {
from the module to the core right now. Here from the module to the core right now. Here
for future compatibility. */ for future compatibility. */
int master; /* true if master, false if replica */ int master; /* true if master, false if replica */
char *masterhost; /* master instance hostname for NOW_REPLICA */ const char *masterhost; /* master instance hostname for NOW_REPLICA */
int masterport; /* master instance port for NOW_REPLICA */ int masterport; /* master instance port for NOW_REPLICA */
char *replid1; /* Main replication ID */ char *replid1; /* Main replication ID */
char *replid2; /* Secondary replication ID */ char *replid2; /* Secondary replication ID */