summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-02-20 10:18:41 +0100
committerantirez <antirez@gmail.com>2017-02-20 10:18:41 +0100
commit76d87f47c7075a04dfd759fc5bd102dfad005dcc (patch)
tree952b8a2ec1ad2672529d8825798f881a8c28ec0b
parentf917e0da4cda8a0e6cd3242180b268706cdd2dd2 (diff)
downloadredis-76d87f47c7075a04dfd759fc5bd102dfad005dcc.tar.gz
Don't leak file descriptor on syncWithMaster().
Close #3804.
-rw-r--r--src/replication.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/replication.c b/src/replication.c
index df2e23f3a..bde37bc43 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -1568,7 +1568,7 @@ int slaveTryPartialResynchronization(int fd, int read_reply) {
* establish a connection with the master. */
void syncWithMaster(aeEventLoop *el, int fd, void *privdata, int mask) {
char tmpfile[256], *err = NULL;
- int dfd, maxtries = 5;
+ int dfd = -1, maxtries = 5;
int sockerr = 0, psync_result;
socklen_t errlen = sizeof(sockerr);
UNUSED(el);
@@ -1832,6 +1832,7 @@ void syncWithMaster(aeEventLoop *el, int fd, void *privdata, int mask) {
error:
aeDeleteFileEvent(server.el,fd,AE_READABLE|AE_WRITABLE);
+ if (dfd != -1) close(dfd);
close(fd);
server.repl_transfer_s = -1;
server.repl_state = REPL_STATE_CONNECT;