summaryrefslogtreecommitdiff
path: root/src/rio.c
diff options
context:
space:
mode:
authorsundb <sundbcn@gmail.com>2021-12-31 20:08:04 +0800
committerGitHub <noreply@github.com>2021-12-31 14:08:04 +0200
commit73951abe7b86a565e3123fc1b8033efdcd1c0c04 (patch)
treef1955e8734808683de4f68c1bd38d02488a93019 /src/rio.c
parente4b3a257eebd0acf0ba7bc5d0902166d02bacfdb (diff)
downloadredis-73951abe7b86a565e3123fc1b8033efdcd1c0c04.tar.gz
Fix when the master connection is disconnected, replication retry read indefinitely (#10032)
Now if redis is still loading when we receive sigterm, we will wait for the loading to reach the event loop (once in 2mb) before actually shutting down. See #10003. This change caused valgrind CI to fail. See https://github.com/redis/redis/runs/4662901673?check_suite_focus=true This pr is mainly to solve the problem that redis process cannot be exited normally. When the master is disconnected, if repl is processing diskless loading and using `connRead` to read data from master, it may enter an infinite retry state, which does not handle `connRead` returning 0(master connection disconnected).
Diffstat (limited to 'src/rio.c')
-rw-r--r--src/rio.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/rio.c b/src/rio.c
index caeaaf3db..f99913152 100644
--- a/src/rio.c
+++ b/src/rio.c
@@ -244,7 +244,9 @@ static size_t rioConnRead(rio *r, void *buf, size_t len) {
int retval = connRead(r->io.conn.conn,
(char*)r->io.conn.buf + sdslen(r->io.conn.buf),
toread);
- if (retval <= 0) {
+ if (retval == 0) {
+ return 0;
+ } else if (retval < 0) {
if (connLastErrorRetryable(r->io.conn.conn)) continue;
if (errno == EWOULDBLOCK) errno = ETIMEDOUT;
return 0;