MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / rdbRemoveTempFile

Function rdbRemoveTempFile

src/rdb.cpp:1727–1741  ·  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_unlik that * is not async-signal-safe. */

Source from the content-addressed store, hash-verified

1725 * If we call this function from signal handle, we won't call bg_unlik that
1726 * is not async-signal-safe. */
1727void rdbRemoveTempFile(int tmpfileNum, int from_signal) {
1728 char tmpfile[256];
1729
1730 getTempFileName(tmpfile, tmpfileNum);
1731
1732 if (from_signal) {
1733 /* bg_unlink is not async-signal-safe, but in this case we don't really
1734 * need to close the fd, it'll be released when the process exists. */
1735 int fd = open(tmpfile, O_RDONLY|O_NONBLOCK);
1736 UNUSED(fd);
1737 unlink(tmpfile);
1738 } else {
1739 bg_unlink(tmpfile);
1740 }
1741}
1742
1743/* This function is called by rdbLoadObject() when the code is in RDB-check
1744 * mode and we find a module value of type 2 that can be parsed without

Callers 3

prepareForShutdownFunction · 0.85
sigShutdownHandlerFunction · 0.85

Calls 2

getTempFileNameFunction · 0.85
bg_unlinkFunction · 0.85

Tested by

no test coverage detected