summaryrefslogtreecommitdiff
path: root/src/rdb.c
diff options
context:
space:
mode:
authorPavel Melkozerov <brain5lug@users.noreply.github.com>2021-11-24 17:01:39 +0300
committerGitHub <noreply@github.com>2021-11-24 16:01:39 +0200
commit9630ded313d593c318ac220ace165319283a74fe (patch)
treeb12f8f13a537aad69c08f2b131957eadfd39d224 /src/rdb.c
parent4512905961b3a2f4c00e5fe7ffff8d96db82861e (diff)
downloadredis-9630ded313d593c318ac220ace165319283a74fe.tar.gz
fix fob bad log messages in rdbSave (#9842) (#9843)
logs message prints wrong file is failed to open temporary file logs have error occurred in getcwd (uses same errno to report error) Co-authored-by: Pavel Melkozerov <pavel.melkozerov@nokia.com>
Diffstat (limited to 'src/rdb.c')
-rw-r--r--src/rdb.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rdb.c b/src/rdb.c
index f3ea05317..64780bbb5 100644
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -1372,13 +1372,14 @@ int rdbSave(char *filename, rdbSaveInfo *rsi) {
snprintf(tmpfile,256,"temp-%d.rdb", (int) getpid());
fp = fopen(tmpfile,"w");
if (!fp) {
+ char *str_err = strerror(errno);
char *cwdp = getcwd(cwd,MAXPATHLEN);
serverLog(LL_WARNING,
- "Failed opening the RDB file %s (in server root dir %s) "
+ "Failed opening the temp RDB file %s (in server root dir %s) "
"for saving: %s",
- filename,
+ tmpfile,
cwdp ? cwdp : "unknown",
- strerror(errno));
+ str_err);
return C_ERR;
}
@@ -1402,6 +1403,7 @@ int rdbSave(char *filename, rdbSaveInfo *rsi) {
/* Use RENAME to make sure the DB file is changed atomically only
* if the generate DB file is ok. */
if (rename(tmpfile,filename) == -1) {
+ char *str_err = strerror(errno);
char *cwdp = getcwd(cwd,MAXPATHLEN);
serverLog(LL_WARNING,
"Error moving temp DB file %s on the final "
@@ -1409,7 +1411,7 @@ int rdbSave(char *filename, rdbSaveInfo *rsi) {
tmpfile,
filename,
cwdp ? cwdp : "unknown",
- strerror(errno));
+ str_err);
unlink(tmpfile);
stopSaving(0);
return C_ERR;