| 1170 | } |
| 1171 | |
| 1172 | ssize_t rdbSaveSingleModuleAux(rio *rdb, int when, moduleType *mt) { |
| 1173 | /* Save a module-specific aux value. */ |
| 1174 | RedisModuleIO io; |
| 1175 | int retval = rdbSaveType(rdb, RDB_OPCODE_MODULE_AUX); |
| 1176 | if (retval == -1) return -1; |
| 1177 | moduleInitIOContext(io,mt,rdb,NULL); |
| 1178 | io.bytes += retval; |
| 1179 | |
| 1180 | /* Write the "module" identifier as prefix, so that we'll be able |
| 1181 | * to call the right module during loading. */ |
| 1182 | retval = rdbSaveLen(rdb,mt->id); |
| 1183 | if (retval == -1) return -1; |
| 1184 | io.bytes += retval; |
| 1185 | |
| 1186 | /* write the 'when' so that we can provide it on loading. add a UINT opcode |
| 1187 | * for backwards compatibility, everything after the MT needs to be prefixed |
| 1188 | * by an opcode. */ |
| 1189 | retval = rdbSaveLen(rdb,RDB_MODULE_OPCODE_UINT); |
| 1190 | if (retval == -1) return -1; |
| 1191 | io.bytes += retval; |
| 1192 | retval = rdbSaveLen(rdb,when); |
| 1193 | if (retval == -1) return -1; |
| 1194 | io.bytes += retval; |
| 1195 | |
| 1196 | /* Then write the module-specific representation + EOF marker. */ |
| 1197 | mt->aux_save(&io,when); |
| 1198 | retval = rdbSaveLen(rdb,RDB_MODULE_OPCODE_EOF); |
| 1199 | if (retval == -1) |
| 1200 | io.error = 1; |
| 1201 | else |
| 1202 | io.bytes += retval; |
| 1203 | |
| 1204 | if (io.ctx) { |
| 1205 | moduleFreeContext(io.ctx); |
| 1206 | zfree(io.ctx); |
| 1207 | } |
| 1208 | if (io.error) |
| 1209 | return -1; |
| 1210 | return io.bytes; |
| 1211 | } |
| 1212 | |
| 1213 | /* Produces a dump of the database in RDB format sending it to the specified |
| 1214 | * Redis I/O channel. On success C_OK is returned, otherwise C_ERR |
no test coverage detected