Fix rdb_child_exit_pipe incorrect close call (#801)

server.rdb_child_exit_pipe is init in !dual_channel block,
so the call here would be close(-1) in !dual_channel way.

It will also generate a warning in valgrind:
Warning: invalid file descriptor -1 in syscall close()

Introduced in #60.

Signed-off-by: Binbin <binloveplay1314@qq.com>
This commit is contained in:
Binbin 2024-07-18 13:47:08 +08:00 committed by GitHub
parent c584371506
commit 36e81d9e79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3604,11 +3604,11 @@ int rdbSaveToReplicasSockets(int req, rdbSaveInfo *rsi) {
rioFreeConnset(&rdb);
} else {
rioFreeFd(&rdb);
/* wake up the reader, tell it we're done. */
close(rdb_pipe_write);
close(server.rdb_child_exit_pipe); /* close write end so that we can detect the close on the parent. */
}
zfree(conns);
/* wake up the reader, tell it we're done. */
close(server.rdb_child_exit_pipe); /* close write end so that we can detect the close on the parent. */
/* hold exit until the parent tells us it's safe. we're not expecting
* to read anything, just get the error when the pipe is closed. */
if (!dual_channel) dummy = read(safe_to_exit_pipe, pipefds, 1);
@ -3632,8 +3632,8 @@ int rdbSaveToReplicasSockets(int req, rdbSaveInfo *rsi) {
if (!dual_channel) {
close(rdb_pipe_write);
close(server.rdb_pipe_read);
close(server.rdb_child_exit_pipe);
}
close(server.rdb_child_exit_pipe);
zfree(conns);
if (dual_channel) {
closeChildInfoPipe();