From 4bce95ac8d637b55d59dadcd890924fcb48d2f3a Mon Sep 17 00:00:00 2001 From: luoliangyi <87842688@qq.com> Date: Wed, 27 Jul 2022 09:18:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/base/HGNamedPipe.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/base/HGNamedPipe.cpp b/modules/base/HGNamedPipe.cpp index 896a8502..3f9b3a06 100644 --- a/modules/base/HGNamedPipe.cpp +++ b/modules/base/HGNamedPipe.cpp @@ -28,8 +28,11 @@ struct HGNamedPipeOutImpl CloseHandle(m_hConnectEvent); m_hConnectEvent = NULL; #else - close(m_fdPipe); - m_fdPipe = -1; + if (-1 != m_fdPipe) + { + close(m_fdPipe); + m_fdPipe = -1; + } unlink(m_filePath.c_str()); #endif } @@ -65,8 +68,11 @@ struct HGNamedPipeInImpl CloseHandle(m_hReadEvent); m_hReadEvent = NULL; #else - close(m_fdPipe); - m_fdPipe = -1; + if (-1 != m_fdPipe) + { + close(m_fdPipe); + m_fdPipe = -1; + } #endif } @@ -221,6 +227,11 @@ HGResult HGAPI HGBase_StopWriteNamedPipe(HGNamedPipeOut pipeOut) SetEvent(pipeOutImpl->m_hConnectEvent); SetEvent(pipeOutImpl->m_hWriteEvent); #else + if (-1 != pipeInImpl->m_fdPipe) + { + close(pipeInImpl->m_fdPipe); + pipeInImpl->m_fdPipe = -1; + } #endif return HGBASE_ERR_OK; } @@ -333,6 +344,11 @@ HGResult HGAPI HGBase_StopReadNamedPipe(HGNamedPipeIn pipeIn) #if defined(HG_CMP_MSC) SetEvent(pipeInImpl->m_hReadEvent); #else + if (-1 != pipeInImpl->m_fdPipe) + { + close(pipeInImpl->m_fdPipe); + pipeInImpl->m_fdPipe = -1; + } #endif return HGBASE_ERR_OK; } \ No newline at end of file