| 1707 | } |
| 1708 | |
| 1709 | void 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. |
no test coverage detected