Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy 'errno' and use copied value in the if check of retry in cluster migrate commands socket_err block. #1042

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ void migrateCommand(client *c) {
int may_retry = 1;
int write_error = 0;
int argv_rewritten = 0;
int errno_copy = 0;

/* To support the KEYS option we need the following additional state. */
int first_key = 3; /* Argument index of the first key. */
Expand Down Expand Up @@ -710,6 +711,10 @@ void migrateCommand(client *c) {
* It is very common for the cached socket to get closed, if just reopening
* it works it's a shame to notify the error to the caller. */
socket_err:
/* Take a copy of 'errno' prior cleanup as it can be overwritten and
* use copied variable for re-try check. */
errno_copy = errno;

/* Cleanup we want to perform in both the retry and no retry case.
* Note: Closing the migrate socket will also force SELECT next time. */
sdsfree(cmd.io.buffer.ptr);
Expand All @@ -724,7 +729,7 @@ void migrateCommand(client *c) {

/* Retry only if it's not a timeout and we never attempted a retry
* (or the code jumping here did not set may_retry to zero). */
if (errno != ETIMEDOUT && may_retry) {
if (errno_copy != ETIMEDOUT && may_retry) {
may_retry = 0;
goto try_again;
}
Expand Down
Loading