-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[15158] ReadConditions Implementation #2872
Conversation
7a6b4d3
to
7c4ed4d
Compare
@@ -304,6 +314,16 @@ DataReaderImpl::~DataReaderImpl() | |||
|
|||
bool DataReaderImpl::can_be_deleted() const | |||
{ | |||
{ | |||
std::lock_guard<std::recursive_mutex> _(get_conditions_mutex()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mutex's scope should cover the whole operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acknowledged. To prevent any issues on notification the get_conditions_mutex()
must be taken after the reader_->getMutex()
one (doxygen on the mutex has been updated) because notification callbacks are done with the reader mutex taken.
Nevertheless the ReturnCode_t SubscriberImpl::delete_datareader(const DataReader* reader)
will not take the mutex between DataReaderImpl::can_be_deleted()
check and the actual deletion.
This happens too for the loans. A mechanism is need to disable all resource allocation within this method (flag or something) and assure can_be_deleted
value will hold through it.
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/ParameterList.cpp | ||
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/QosPolicyUtils.cpp | ||
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/QosPolicyUtils.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicated line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
4398b7d
to
a3dce99
Compare
@MiguelBarro I think I got #2842 finally right. Would you mind rebasing this? |
6586676
to
b08745f
Compare
b08745f
to
4eb8f91
Compare
4eb8f91
to
d925e4e
Compare
@richiprosima Please test this for me 🤯 |
8de1e55
to
891142b
Compare
@MiguelBarro #2842 has been merged. This one can be rebased onto master |
} | ||
conds.clear(); | ||
|
||
// 4- Create several ReadConditions associated to different same masks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different same masks? Please clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
conds.push_front(reader.create_readcondition( ++sample_states, ++view_states, ++instance_states)); | ||
} | ||
|
||
EXPECT_EQ(reader.delete_contained_entities(), ReturnCode_t::RETCODE_OK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the functionality of delete_contained_entities changed its tests should reflect this by adding new test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the possible cases are tested here:
Fast-DDS/test/unittest/dds/subscriber/DataReaderTests.cpp
Lines 2660 to 2665 in 6396f33
// 7- Check the DataReader cannot be deleted with outstanding conditions | |
EXPECT_EQ(subscriber_->delete_datareader(another_reader), ReturnCode_t::RETCODE_PRECONDITION_NOT_MET); | |
// but delete_contained_entities() succeeds with outstanding ReadConditions | |
EXPECT_EQ(another_reader->delete_contained_entities(), ReturnCode_t::RETCODE_OK); | |
// no outstanding conditions (killed above) | |
EXPECT_EQ(subscriber_->delete_datareader(another_reader), ReturnCode_t::RETCODE_OK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was referring to adding ReadConditions deletion to this test. I think that's where the delete_contained_entities functionality tests should go (even if you are using and checking its return code elsewhere)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 👍
|
||
#include <fastdds/dds/subscriber/ReadCondition.hpp> | ||
#include <fastdds/dds/core/StackAllocatedSequence.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the style guide, this line should come before the previous one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file has been removed in favor of DataReaderTests.cpp
InstanceStateMask instance_states = ANY_INSTANCE_STATE; | ||
EXPECT_EQ( | ||
nullptr, | ||
data_reader->create_readcondition(sample_states, view_states, instance_states)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove create_readcondition from the list of unimplemented methods in this test comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
{ | ||
EXPECT_EQ( | ||
ReturnCode_t::RETCODE_UNSUPPORTED, | ||
data_reader->delete_readcondition(nullptr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove delete_readcondition from the list of unimplemented methods in this test comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
EXPECT_EQ(reader.delete_readcondition(cond), ReturnCode_t::RETCODE_PRECONDITION_NOT_MET); | ||
|
||
// 7- Check the DataReader cannot be deleted with outstanding conditions | ||
EXPECT_EQ(another_manager.get_native_subscriber().delete_contained_entities(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the existence of ReadConditions should cause the delete_contained_entities call to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a) ReturnCode_t DataReaderImpl::delete_contained_entities()
My implementation clears all ReadConditions (we can do that because Company implementation unlinks the WaitSets on Condition destruction.
According to the DDS standard 1.4 in 2.2.2.2.1.18 & 2.2.2.5.3.31 delete_contained_entities() will be used recursively and remove all API created objects (including Read & QueryConditions object created by the DataReader).
The operation will return PRECONDITION_NOT_MET if the any of the contained entities is in a state where it cannot be deleted. This is quite vague but seems our DataReaderImpl fulfills the spirit.
b) ReturnCode_t SubscriberImpl::delete_contained_entities()
The implementation tries to destroy all DataReaders checking DataReaderImpl::can_be_deleted().
My can_be_deleted() implementation takes into account outstanding ReadConditions (formerly only loans).
This doesn't match the DDS standard 2.2.2.5.2.14 behaviour.
c) ReturnCode_t SubscriberImpl::delete_datareader(const DataReader* reader)
The implementation tries to destroy all the readers querying can_be_deleted() too.
This matches standard 2.2.2.5.2.6 description (any outstanding ReadConditions will lead to failure).
It's clear the issue is b). b) and c) are supposed to behave differently but are calling the same DataReaderImpl::can_be_deleted()
method. The solution is make clear to the method which function is calling it by using a parameter as:
bool DataReaderImpl::can_be_deleted(bool recursive = true) const
// Check the data is there | ||
EXPECT_EQ(reader.get_native_reader().get_unread_count(), 1); | ||
|
||
// Check the conditions triggered where the expected ones |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: Replace where with were
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
…ies component. This pull request mandatory piggyback. Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
…read_conditions) Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
…hecks Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Signed-off-by: Miguel Barro <miguel.barro@live.com>
…2872, some methods of DataReader.hpp are going to be implemented. This commit removes the not-supported warning for the merge. Signed-off-by: Mikel Rico <mikelrico@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
bf26dca
to
75ea11b
Compare
…2879) * Refs #14686: Add warning to indicate unsupported APIs in DomainParticipant.hpp Signed-off-by: Mikel Rico <mikelrico@eprosima.com> * Refs #14686: Add warning to indicate unsupported APIs in DomainParticipantFactory.hpp Signed-off-by: Mikel Rico <mikelrico@eprosima.com> * Refs #14686: Add warning to indicate unsupported APIs in DataWriter.hpp Signed-off-by: Mikel Rico <mikelrico@eprosima.com> * Refs #14686: Add warning to indicate unsupported APIs in Publisher.hpp Signed-off-by: Mikel Rico <mikelrico@eprosima.com> * Refs #14686: Add warning to indicate unsupported APIs in DataReader.hpp Signed-off-by: Mikel Rico <mikelrico@eprosima.com> * Refs #14686: Add warning to indicate unsupported APIs in Subscriber.hpp Signed-off-by: Mikel Rico <mikelrico@eprosima.com> * Refs #14686: Add warning to indicate unsupported APIs in Topic.hpp Signed-off-by: Mikel Rico <mikelrico@eprosima.com> * Refs #14686: In accordance with [15158] ReadConditions Implementation #2872, some methods of DataReader.hpp are going to be implemented. This commit removes the not-supported warning for the merge. Signed-off-by: Mikel Rico <mikelrico@eprosima.com>
@richiprosima Please test this |
// Should failed with outstanding ReadConditions | ||
ASSERT_EQ(subscriber->delete_datareader(data_reader), ReturnCode_t::RETCODE_PRECONDITION_NOT_MET); | ||
|
||
std::cout << "Before recursive?" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove trace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right
@@ -2580,7 +2587,17 @@ TEST_F(DataReaderTests, delete_contained_entities) | |||
// To be updated when Query Conditions are available | |||
ASSERT_EQ(query_condition, nullptr); | |||
|
|||
std::cout << "check non-recursive?" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove trace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ASSERT_EQ(data_reader->delete_contained_entities(), ReturnCode_t::RETCODE_OK); | ||
|
||
std::cout << "Where is the SEH?" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope it's nowhere to be seen. Please remove this trace 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -2580,7 +2587,17 @@ TEST_F(DataReaderTests, delete_contained_entities) | |||
// To be updated when Query Conditions are available | |||
ASSERT_EQ(query_condition, nullptr); | |||
|
|||
std::cout << "check non-recursive?" << std::endl; | |||
|
|||
// Should failed with outstanding ReadConditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: failed -> fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
std::cout << "Before recursive?" << std::endl; | ||
|
||
// Should not failed with outstanding ReadConditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: failed -> fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
53002ba
to
66e7784
Compare
Signed-off-by: Miguel Barro <miguel.barro@live.com>
66e7784
to
65c58a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@richiprosima please test this |
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Barro <miguel.barro@live.com>
@richiprosima please test this |
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
@richiprosima Please test windows |
@richiprosima Please test mac and test linux |
…thods. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
…e_deleted. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
e0a125c
to
9774494
Compare
@richiprosima Please test this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Description
ReadCondition DDS 1.4 feature implementation & testing
Contributor Checklist
versions.md
file (if applicable).Reviewer Checklist