MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rdbSaveRioWithEOFMark

Function rdbSaveRioWithEOFMark

app/redis-6.2.6/src/rdb.c:1333–1352  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

1331 * This way processes receiving the payload can understand when it ends
1332 * without doing any processing of the content. */
1333int 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
1347werr: /* 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. */
1355int rdbSave(char *filename, rdbSaveInfo *rsi) {

Callers 1

rdbSaveToSlavesSocketsFunction · 0.85

Calls 5

startSavingFunction · 0.85
getRandomHexCharsFunction · 0.85
rioWriteFunction · 0.85
rdbSaveRioFunction · 0.85
stopSavingFunction · 0.85

Tested by

no test coverage detected