rdb: corrected RedisModuleIO initialization point (#8014)
- rdbSaveSingleModuleAux() used RedisModuleIO's "bytes" field for tracking written bytes before calling moduleInitIOContext() which sets "bytes" to zero - rdbSaveObject() re-initialized RedisModuleIO too late This return value is not used at the moment since it's only tested against -1, and the actual byte count isn't used yet. Co-authored-by: Tomasz Poradowski <tomasz.poradowski@generiscorp.com>
This commit is contained in:
parent
0ce56054c3
commit
d480eb05da
@ -1015,10 +1015,10 @@ ssize_t rdbSaveObject(rio *rdb, robj *o, robj *key) {
|
|||||||
* to call the right module during loading. */
|
* to call the right module during loading. */
|
||||||
int retval = rdbSaveLen(rdb,mt->id);
|
int retval = rdbSaveLen(rdb,mt->id);
|
||||||
if (retval == -1) return -1;
|
if (retval == -1) return -1;
|
||||||
|
moduleInitIOContext(io,mt,rdb,key);
|
||||||
io.bytes += retval;
|
io.bytes += retval;
|
||||||
|
|
||||||
/* Then write the module-specific representation + EOF marker. */
|
/* Then write the module-specific representation + EOF marker. */
|
||||||
moduleInitIOContext(io,mt,rdb,key);
|
|
||||||
mt->rdb_save(&io,mv->value);
|
mt->rdb_save(&io,mv->value);
|
||||||
retval = rdbSaveLen(rdb,RDB_MODULE_OPCODE_EOF);
|
retval = rdbSaveLen(rdb,RDB_MODULE_OPCODE_EOF);
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
@ -1147,6 +1147,7 @@ ssize_t rdbSaveSingleModuleAux(rio *rdb, int when, moduleType *mt) {
|
|||||||
RedisModuleIO io;
|
RedisModuleIO io;
|
||||||
int retval = rdbSaveType(rdb, RDB_OPCODE_MODULE_AUX);
|
int retval = rdbSaveType(rdb, RDB_OPCODE_MODULE_AUX);
|
||||||
if (retval == -1) return -1;
|
if (retval == -1) return -1;
|
||||||
|
moduleInitIOContext(io,mt,rdb,NULL);
|
||||||
io.bytes += retval;
|
io.bytes += retval;
|
||||||
|
|
||||||
/* Write the "module" identifier as prefix, so that we'll be able
|
/* Write the "module" identifier as prefix, so that we'll be able
|
||||||
@ -1166,7 +1167,6 @@ ssize_t rdbSaveSingleModuleAux(rio *rdb, int when, moduleType *mt) {
|
|||||||
io.bytes += retval;
|
io.bytes += retval;
|
||||||
|
|
||||||
/* Then write the module-specific representation + EOF marker. */
|
/* Then write the module-specific representation + EOF marker. */
|
||||||
moduleInitIOContext(io,mt,rdb,NULL);
|
|
||||||
mt->aux_save(&io,when);
|
mt->aux_save(&io,when);
|
||||||
retval = rdbSaveLen(rdb,RDB_MODULE_OPCODE_EOF);
|
retval = rdbSaveLen(rdb,RDB_MODULE_OPCODE_EOF);
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user