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

Function getTempFileName

src/rdb.cpp:1709–1721  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1707}
1708
1709void getTempFileName(char tmpfile[], int tmpfileNum) {
1710 char pid[32];
1711 char tmpfileNumString[214];
1712
1713 /* Generate temp rdb file name using aync-signal safe functions. */
1714 int pid_len = ll2string(pid, sizeof(pid), g_pserver->in_fork_child ? getppid() : getpid());
1715 int tmpfileNum_len = ll2string(tmpfileNumString, sizeof(tmpfileNumString), tmpfileNum);
1716 strcpy(tmpfile, "temp-");
1717 strncpy(tmpfile+5, pid, pid_len);
1718 strcpy(tmpfile+5+pid_len, "-");
1719 strncpy(tmpfile+5+pid_len+1, tmpfileNumString, tmpfileNum_len);
1720 strcpy(tmpfile+5+pid_len+1+tmpfileNum_len, ".rdb");
1721}
1722
1723/* Note that we may call this function in signal handle 'sigShutdownHandler',
1724 * so we need guarantee all functions we call are async-signal-safe.

Callers 3

rdbSaveFileFunction · 0.85
rdbRemoveTempFileFunction · 0.85
debugCommandFunction · 0.85

Calls 1

ll2stringFunction · 0.85

Tested by

no test coverage detected