From 98b4828e9315408acce234a99a1ec8a1f800d234 Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Tue, 19 Mar 2024 08:24:11 +0300 Subject: [PATCH] Update IXSelectInterruptPipe.cpp (#502) Valgrind keeps complaining that close() on the invalid descriptor -1 is happening here. I suppose that close shouldn't be called when the descriptor value is known to be invalid. It's not a fatal error or something, but this practice is able to create a lot of flood in the logs. --- ixwebsocket/IXSelectInterruptPipe.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ixwebsocket/IXSelectInterruptPipe.cpp b/ixwebsocket/IXSelectInterruptPipe.cpp index 75c42f27..0518994a 100644 --- a/ixwebsocket/IXSelectInterruptPipe.cpp +++ b/ixwebsocket/IXSelectInterruptPipe.cpp @@ -34,8 +34,12 @@ namespace ix SelectInterruptPipe::~SelectInterruptPipe() { - ::close(_fildes[kPipeReadIndex]); - ::close(_fildes[kPipeWriteIndex]); + if (-1 != _fildes[kPipeReadIndex]) { + ::close(_fildes[kPipeReadIndex]); + } + if (-1 != _fildes[kPipeWriteIndex]) { + ::close(_fildes[kPipeWriteIndex]); + } _fildes[kPipeReadIndex] = -1; _fildes[kPipeWriteIndex] = -1; }