Save open's errno when opening temp rdb fails to prevent it from being modified (#1347)
Apparently on Mac, sleep will modify errno to ETIMEDOUT, and then it prints the misleading message: Operation timed out. Signed-off-by: Binbin <binloveplay1314@qq.com>
This commit is contained in:
parent
cf1a1e0931
commit
2d48a39c27
@ -3688,7 +3688,11 @@ void syncWithPrimary(connection *conn) {
|
||||
snprintf(tmpfile, 256, "temp-%d.%ld.rdb", (int)server.unixtime, (long int)getpid());
|
||||
dfd = open(tmpfile, O_CREAT | O_WRONLY | O_EXCL, 0644);
|
||||
if (dfd != -1) break;
|
||||
/* We save the errno of open to prevent some systems from modifying it after
|
||||
* the sleep call. For example, sleep in Mac will change errno to ETIMEDOUT. */
|
||||
int saved_errno = errno;
|
||||
sleep(1);
|
||||
errno = saved_errno;
|
||||
}
|
||||
if (dfd == -1) {
|
||||
serverLog(LL_WARNING, "Opening the temp file needed for PRIMARY <-> REPLICA synchronization: %s",
|
||||
|
Loading…
x
Reference in New Issue
Block a user