Skip to content

Commit

Permalink
Merge pull request #151 from elBoberido/iox-#150-fix-destroy-method-o…
Browse files Browse the repository at this point in the history
…f-message-queue-and-unix-domain-socket-abstraction

iox-#150 fix-destroy-method-of-message-queue-and-unix-domain-socket
  • Loading branch information
elBoberido authored Jun 24, 2020
2 parents 0899210 + f60eff7 commit 8274cd5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions iceoryx_utils/source/posix_wrapper/message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ cxx::expected<IpcChannelError> MessageQueue::destroy()
}

m_mqDescriptor = INVALID_DESCRIPTOR;
m_isInitialized = false;
return cxx::success<void>();
}

Expand Down
2 changes: 2 additions & 0 deletions iceoryx_utils/source/posix_wrapper/unix_domain_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ UnixDomainSocket& UnixDomainSocket::operator=(UnixDomainSocket&& other) noexcept
m_sockAddr = std::move(other.m_sockAddr);
other.m_sockfd = INVALID_FD;
m_maxMessageSize = std::move(other.m_maxMessageSize);
moveCreationPatternValues(std::move(other));
}

return *this;
Expand Down Expand Up @@ -128,6 +129,7 @@ cxx::expected<IpcChannelError> UnixDomainSocket::destroy() noexcept
}

m_sockfd = INVALID_FD;
m_isInitialized = false;

return cxx::success<void>();
}
Expand Down
8 changes: 8 additions & 0 deletions iceoryx_utils/test/moduletests/test_message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ TEST_F(MessageQueue_test, sendAndReceive)
EXPECT_EQ(anotherMessage, *receivedMessage);
}

TEST_F(MessageQueue_test, invalidAfterDestroy)
{
client.destroy();
ASSERT_FALSE(client.isInitialized());
server.destroy();
ASSERT_FALSE(server.isInitialized());
}

TEST_F(MessageQueue_test, sendAfterClientDestroy)
{
auto dest = client.destroy();
Expand Down

0 comments on commit 8274cd5

Please sign in to comment.