This is just a wrapper to rdbSaveRio() that additionally adds a prefix * and a suffix to the generated RDB dump. The prefix is: * * $EOF:<40 bytes unguessable hex string>\r\n * * While the suffix is the 40 bytes hex string we announced in the prefix. * This way processes receiving the payload can understand when it ends * without doing any processing of the content. */
| 1331 | * This way processes receiving the payload can understand when it ends |
| 1332 | * without doing any processing of the content. */ |
| 1333 | int rdbSaveRioWithEOFMark(rio *rdb, int *error, rdbSaveInfo *rsi) { |
| 1334 | char eofmark[RDB_EOF_MARK_SIZE]; |
| 1335 | |
| 1336 | startSaving(RDBFLAGS_REPLICATION); |
| 1337 | getRandomHexChars(eofmark,RDB_EOF_MARK_SIZE); |
| 1338 | if (error) *error = 0; |
| 1339 | if (rioWrite(rdb,"$EOF:",5) == 0) goto werr; |
| 1340 | if (rioWrite(rdb,eofmark,RDB_EOF_MARK_SIZE) == 0) goto werr; |
| 1341 | if (rioWrite(rdb,"\r\n",2) == 0) goto werr; |
| 1342 | if (rdbSaveRio(rdb,error,RDBFLAGS_NONE,rsi) == C_ERR) goto werr; |
| 1343 | if (rioWrite(rdb,eofmark,RDB_EOF_MARK_SIZE) == 0) goto werr; |
| 1344 | stopSaving(1); |
| 1345 | return C_OK; |
| 1346 | |
| 1347 | werr: /* Write error. */ |
| 1348 | /* Set 'error' only if not already set by rdbSaveRio() call. */ |
| 1349 | if (error && *error == 0) *error = errno; |
| 1350 | stopSaving(0); |
| 1351 | return C_ERR; |
| 1352 | } |
| 1353 | |
| 1354 | /* Save the DB on disk. Return C_ERR on error, C_OK on success. */ |
| 1355 | int rdbSave(char *filename, rdbSaveInfo *rsi) { |
no test coverage detected