From 20cfb91f3fedf4a376ea0ca7eb749ca8aaaf50bc Mon Sep 17 00:00:00 2001 From: John Sully Date: Mon, 15 Jul 2019 14:55:41 -0400 Subject: [PATCH] Crash when aborting SYNC with a master on a thread other than main Former-commit-id: a19d0f67b9fffefd9029b9a2ef3358b110302bbf --- src/replication.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/replication.cpp b/src/replication.cpp index c782e7aa7..14ee002aa 100644 --- a/src/replication.cpp +++ b/src/replication.cpp @@ -2198,8 +2198,10 @@ int connectWithMaster(redisMaster *mi) { void undoConnectWithMaster(redisMaster *mi) { int fd = mi->repl_transfer_s; - aeDeleteFileEvent(g_pserver->rgthreadvar[IDX_EVENT_LOOP_MAIN].el,fd,AE_READABLE|AE_WRITABLE); - close(fd); + aePostFunction(g_pserver->rgthreadvar[IDX_EVENT_LOOP_MAIN].el, [fd]{ + aeDeleteFileEvent(g_pserver->rgthreadvar[IDX_EVENT_LOOP_MAIN].el,fd,AE_READABLE|AE_WRITABLE); + close(fd); + }); mi->repl_transfer_s = -1; }