Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 27df922

Browse files
Treat a -1 response from cluster_check_response as a timeout.
When cluster_check_response returns -1 this can be treated as a timeout. Note that there is one non-timout condition which can cause a -1 response, but that is a corrupted MOVE/ASK reply which can *probably* be treated as a timeout as well, because it means that something has gone horribly wrong with the connection. Addresses #1425
1 parent 2e41237 commit 27df922

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

cluster_library.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,8 +1439,9 @@ PHP_REDIS_API short cluster_send_command(redisCluster *c, short slot, const char
14391439
}
14401440
}
14411441

1442-
/* Figure out if we've timed out trying to read or write the data */
1443-
timedout = resp && c->waitms ? mstime() - msstart >= c->waitms : 0;
1442+
/* We're timed out if cluster_check_response returned -1, or if the
1443+
* response was non-zero and we've been in the loop too long */
1444+
timedout = resp == -1 || (resp && c->waitms ? mstime() - msstart >= c->waitms : 0);
14441445
} while (resp != 0 && !c->clusterdown && !timedout);
14451446

14461447
// If we've detected the cluster is down, throw an exception

0 commit comments

Comments
 (0)