From 959c6b8a19b64437941769c6202b415d266dee65 Mon Sep 17 00:00:00 2001 From: John Sully Date: Thu, 4 Jun 2020 00:25:37 -0400 Subject: [PATCH] Disambiguate temp rdb files so its less likely two servers with the same working dir will collide Former-commit-id: 8fbc5a63c54589bb42aa1b1b53c56f399211605c --- src/rdb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rdb.cpp b/src/rdb.cpp index 775799b3d..befb43430 100644 --- a/src/rdb.cpp +++ b/src/rdb.cpp @@ -1375,7 +1375,7 @@ int rdbSaveFile(char *filename, const redisDbPersistentDataSnapshot **rgpdb, rdb rio rdb; int error = 0; - snprintf(tmpfile,256,"temp-%d.rdb", g_pserver->rdbThreadVars.tmpfileNum); + snprintf(tmpfile,256,"temp-%d-%d.rdb", getpid(), g_pserver->rdbThreadVars.tmpfileNum); fp = fopen(tmpfile,"w"); if (!fp) { char *cwdp = getcwd(cwd,MAXPATHLEN); @@ -1539,7 +1539,7 @@ int rdbSaveBackground(rdbSaveInfo *rsi) { void rdbRemoveTempFile(int tmpfileNum) { char tmpfile[256]; - snprintf(tmpfile,sizeof(tmpfile),"temp-%d.rdb", tmpfileNum); + snprintf(tmpfile,sizeof(tmpfile),"temp-%d-%d.rdb", getpid(), tmpfileNum); unlink(tmpfile); }