Skip to content

Commit

Permalink
smaller scope
Browse files Browse the repository at this point in the history
Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Nov 25, 2024
1 parent 5412d36 commit 20465eb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -3684,18 +3684,17 @@ void syncWithPrimary(connection *conn) {

/* Prepare a suitable temp file for bulk transfer */
if (!useDisklessLoad()) {
/* 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;
while (maxtries--) {
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;
saved_errno = errno;
/* 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) {
errno = saved_errno;
serverLog(LL_WARNING, "Opening the temp file needed for PRIMARY <-> REPLICA synchronization: %s",
strerror(errno));
goto error;
Expand Down

0 comments on commit 20465eb

Please sign in to comment.