Skip to content

Commit

Permalink
iox-eclipse-iceoryx#381 Return success if file descriptor is already …
Browse files Browse the repository at this point in the history
…closed

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
  • Loading branch information
mossmaurice committed Feb 11, 2021
1 parent f4ee4c9 commit e5d069b
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions iceoryx_utils/source/posix_wrapper/unix_domain_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,29 @@ cxx::expected<bool, IpcChannelError> UnixDomainSocket::unlinkIfExists(const NoPa

cxx::expected<IpcChannelError> UnixDomainSocket::closeFileDescriptor() noexcept
{
auto closeCall =
cxx::makeSmartC(closePlatformFileHandle, cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, {ERROR_CODE}, {}, m_sockfd);

if (!closeCall.hasErrors())
if (m_sockfd != INVALID_FD)
{
if (IpcChannelSide::SERVER == m_channelSide)
auto closeCall = cxx::makeSmartC(
closePlatformFileHandle, cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, {ERROR_CODE}, {}, m_sockfd);

if (!closeCall.hasErrors())
{
unlink(m_sockAddr.sun_path);
}
if (IpcChannelSide::SERVER == m_channelSide)
{
unlink(m_sockAddr.sun_path);
}

m_sockfd = INVALID_FD;
m_isInitialized = false;
m_sockfd = INVALID_FD;
m_isInitialized = false;

return cxx::success<void>();
}
else
{
return createErrorFromErrnum(closeCall.getErrNum());
return cxx::success<void>();
}
else
{
return createErrorFromErrnum(closeCall.getErrNum());
}
}
return cxx::success<>();
}

cxx::expected<IpcChannelError> UnixDomainSocket::destroy() noexcept
Expand Down

0 comments on commit e5d069b

Please sign in to comment.