| 1263 | } |
| 1264 | |
| 1265 | ssize_t rdbSaveSingleModuleAux(rio *rdb, int when, moduleType *mt) { |
| 1266 | /* Save a module-specific aux value. */ |
| 1267 | RedisModuleIO io; |
| 1268 | int retval = rdbSaveType(rdb, RDB_OPCODE_MODULE_AUX); |
| 1269 | if (retval == -1) return -1; |
| 1270 | moduleInitIOContext(io,mt,rdb,NULL); |
| 1271 | io.bytes += retval; |
| 1272 | |
| 1273 | /* Write the "module" identifier as prefix, so that we'll be able |
| 1274 | * to call the right module during loading. */ |
| 1275 | retval = rdbSaveLen(rdb,mt->id); |
| 1276 | if (retval == -1) return -1; |
| 1277 | io.bytes += retval; |
| 1278 | |
| 1279 | /* write the 'when' so that we can provide it on loading. add a UINT opcode |
| 1280 | * for backwards compatibility, everything after the MT needs to be prefixed |
| 1281 | * by an opcode. */ |
| 1282 | retval = rdbSaveLen(rdb,RDB_MODULE_OPCODE_UINT); |
| 1283 | if (retval == -1) return -1; |
| 1284 | io.bytes += retval; |
| 1285 | retval = rdbSaveLen(rdb,when); |
| 1286 | if (retval == -1) return -1; |
| 1287 | io.bytes += retval; |
| 1288 | |
| 1289 | /* Then write the module-specific representation + EOF marker. */ |
| 1290 | mt->aux_save(&io,when); |
| 1291 | retval = rdbSaveLen(rdb,RDB_MODULE_OPCODE_EOF); |
| 1292 | if (retval == -1) |
| 1293 | io.error = 1; |
| 1294 | else |
| 1295 | io.bytes += retval; |
| 1296 | |
| 1297 | if (io.ctx) { |
| 1298 | moduleFreeContext(io.ctx); |
| 1299 | zfree(io.ctx); |
| 1300 | } |
| 1301 | if (io.error) |
| 1302 | return -1; |
| 1303 | return io.bytes; |
| 1304 | } |
| 1305 | |
| 1306 | /* Produces a dump of the database in RDB format sending it to the specified |
| 1307 | * Redis I/O channel. On success C_OK is returned, otherwise C_ERR |
no test coverage detected