MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / rdbLoadCheckModuleValue

Function rdbLoadCheckModuleValue

src/rdb.cpp:1747–1780  ·  view source on GitHub ↗

This function is called by rdbLoadObject() when the code is in RDB-check * mode and we find a module value of type 2 that can be parsed without * the need of the actual module. The value is parsed for errors, finally * a dummy redis object is returned just to conform to the API. */

Source from the content-addressed store, hash-verified

1745 * the need of the actual module. The value is parsed for errors, finally
1746 * a dummy redis object is returned just to conform to the API. */
1747robj *rdbLoadCheckModuleValue(rio *rdb, char *modulename) {
1748 uint64_t opcode;
1749 while((opcode = rdbLoadLen(rdb,NULL)) != RDB_MODULE_OPCODE_EOF) {
1750 if (opcode == RDB_MODULE_OPCODE_SINT ||
1751 opcode == RDB_MODULE_OPCODE_UINT)
1752 {
1753 uint64_t len;
1754 if (rdbLoadLenByRef(rdb,NULL,&len) == -1) {
1755 rdbReportCorruptRDB(
1756 "Error reading integer from module %s value", modulename);
1757 }
1758 } else if (opcode == RDB_MODULE_OPCODE_STRING) {
1759 robj *o = (robj*)rdbGenericLoadStringObject(rdb,RDB_LOAD_NONE,NULL);
1760 if (o == NULL) {
1761 rdbReportCorruptRDB(
1762 "Error reading string from module %s value", modulename);
1763 }
1764 decrRefCount(o);
1765 } else if (opcode == RDB_MODULE_OPCODE_FLOAT) {
1766 float val;
1767 if (rdbLoadBinaryFloatValue(rdb,&val) == -1) {
1768 rdbReportCorruptRDB(
1769 "Error reading float from module %s value", modulename);
1770 }
1771 } else if (opcode == RDB_MODULE_OPCODE_DOUBLE) {
1772 double val;
1773 if (rdbLoadBinaryDoubleValue(rdb,&val) == -1) {
1774 rdbReportCorruptRDB(
1775 "Error reading double from module %s value", modulename);
1776 }
1777 }
1778 }
1779 return createStringObject("module-dummy-value",18);
1780}
1781
1782/* Load a Redis object of the specified type from the specified file.
1783 * On success a newly allocated object is returned, otherwise NULL.

Callers 3

rdbLoadObjectFunction · 0.85
rdbLoadRioFunction · 0.85
redis_check_rdbFunction · 0.85

Calls 7

rdbLoadLenFunction · 0.85
rdbLoadLenByRefFunction · 0.85
decrRefCountFunction · 0.85
rdbLoadBinaryFloatValueFunction · 0.85
rdbLoadBinaryDoubleValueFunction · 0.85
createStringObjectFunction · 0.70

Tested by

no test coverage detected