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

Function rdbRemoveTempFile

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

Note that we may call this function in signal handle 'sigShutdownHandler', * so we need guarantee all functions we call are async-signal-safe. * If we call this function from signal handle, we won't call bg_unlink that * is not async-signal-safe. */

Source from the content-addressed store, hash-verified

1461 * If we call this function from signal handle, we won't call bg_unlink that
1462 * is not async-signal-safe. */
1463void rdbRemoveTempFile(pid_t childpid, int from_signal) {
1464 char tmpfile[256];
1465 char pid[32];
1466
1467 /* Generate temp rdb file name using aync-signal safe functions. */
1468 int pid_len = ll2string(pid, sizeof(pid), childpid);
1469 strcpy(tmpfile, "temp-");
1470 strncpy(tmpfile+5, pid, pid_len);
1471 strcpy(tmpfile+5+pid_len, ".rdb");
1472
1473 if (from_signal) {
1474 /* bg_unlink is not async-signal-safe, but in this case we don't really
1475 * need to close the fd, it'll be released when the process exists. */
1476 int fd = open(tmpfile, O_RDONLY|O_NONBLOCK);
1477 UNUSED(fd);
1478 unlink(tmpfile);
1479 } else {
1480 bg_unlink(tmpfile);
1481 }
1482}
1483
1484/* This function is called by rdbLoadObject() when the code is in RDB-check
1485 * mode and we find a module value of type 2 that can be parsed without

Callers 3

prepareForShutdownFunction · 0.85
sigShutdownHandlerFunction · 0.85

Calls 3

ll2stringFunction · 0.85
strncpyFunction · 0.85
bg_unlinkFunction · 0.85

Tested by

no test coverage detected