Skip to content

Commit f269c38

Browse files
cferreiragonzmergify[bot]
authored andcommitted
Avoid sending duplicated ACKs in DataSharing (#5986)
* Refs #23603: Avoid duplicate ACK in datasharing Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #23603: Doxygen Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> * Refs #23603: Mock method Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> --------- Signed-off-by: cferreiragonz <carlosferreira@eprosima.com> (cherry picked from commit 8421fb0) # Conflicts: # include/fastdds/rtps/reader/StatefulReader.h # include/fastdds/rtps/reader/StatelessReader.h # src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp # src/cpp/rtps/reader/BaseReader.hpp # src/cpp/rtps/reader/StatefulReader.cpp # src/cpp/rtps/reader/StatelessReader.cpp # test/mock/rtps/RTPSReader/rtps/reader/BaseReader.hpp
1 parent 28529b7 commit f269c38

File tree

7 files changed

+733
-2
lines changed

7 files changed

+733
-2
lines changed

include/fastdds/rtps/reader/StatefulReader.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ class StatefulReader : public RTPSReader
308308

309309
/**
310310
* Called after the change has been deserialized.
311+
<<<<<<< HEAD:include/fastdds/rtps/reader/StatefulReader.h
311312
* @param [in] change Pointer to the change being accessed.
312313
* @param [in] wp Writer proxy the @c change belongs to.
313314
* @param [in] mark_as_read Whether the @c change should be marked as read or not.
@@ -316,6 +317,18 @@ class StatefulReader : public RTPSReader
316317
CacheChange_t* change,
317318
WriterProxy*& wp,
318319
bool mark_as_read) override;
320+
=======
321+
* @param [in] change Pointer to the change being accessed.
322+
* @param [in] writer Writer proxy the @c change belongs to.
323+
* @param [in] mark_as_read Whether the @c change should be marked as read or not.
324+
* @param [in] should_send_ack Whether an ACKNACK should be sent to the writer or not.
325+
*/
326+
void end_sample_access_nts(
327+
CacheChange_t* change,
328+
WriterProxy*& writer,
329+
bool mark_as_read,
330+
bool should_send_ack = false) override;
331+
>>>>>>> 8421fb02 (Avoid sending duplicated ACKs in DataSharing (#5986)):src/cpp/rtps/reader/StatefulReader.hpp
319332

320333
/**
321334
* Called when the user has retrieved a change from the history.

include/fastdds/rtps/reader/StatelessReader.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ class StatelessReader : public RTPSReader
233233

234234
/**
235235
* Called after the change has been deserialized.
236+
<<<<<<< HEAD:include/fastdds/rtps/reader/StatelessReader.h
236237
* @param [in] change Pointer to the change being accessed.
237238
* @param [in] wp Writer proxy the @c change belongs to.
238239
* @param [in] mark_as_read Whether the @c change should be marked as read or not.
@@ -241,6 +242,18 @@ class StatelessReader : public RTPSReader
241242
CacheChange_t* change,
242243
WriterProxy*& wp,
243244
bool mark_as_read) override;
245+
=======
246+
* @param [in] change Pointer to the change being accessed.
247+
* @param [in] writer Writer proxy the @c change belongs to.
248+
* @param [in] mark_as_read Whether the @c change should be marked as read or not.
249+
* @param [in] should_send_ack Whether an ACKNACK should be sent to the writer or not.
250+
*/
251+
void end_sample_access_nts(
252+
CacheChange_t* change,
253+
WriterProxy*& writer,
254+
bool mark_as_read,
255+
bool should_send_ack = false) override;
256+
>>>>>>> 8421fb02 (Avoid sending duplicated ACKs in DataSharing (#5986)):src/cpp/rtps/reader/StatelessReader.hpp
244257

245258
/**
246259
* Called when the user has retrieved a change from the history.

src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ struct ReadTakeCommand
148148
ReturnCode_t previous_return_value = return_value_;
149149
bool added = add_sample(*it, remove_change);
150150
history_.change_was_processed_nts(change, added);
151+
<<<<<<< HEAD
151152
reader_->end_sample_access_nts(change, wp, added);
153+
=======
154+
>>>>>>> 8421fb02 (Avoid sending duplicated ACKs in DataSharing (#5986))
152155

153156
// Check if the payload is dirty
154157
if (added && !check_datasharing_validity(change, data_values_.has_ownership()))
@@ -166,7 +169,11 @@ struct ReadTakeCommand
166169
added = false;
167170
}
168171

169-
if (remove_change || (added && take_samples))
172+
// Only send ACK if the change will not be removed to avoid sending the same ACK twice
173+
bool should_remove = remove_change || (added && take_samples);
174+
rtps::BaseReader::downcast(reader_)->end_sample_access_nts(change, wp, added, !should_remove);
175+
176+
if (should_remove)
170177
{
171178
// Remove from history
172179
history_.remove_change_sub(change, it);

0 commit comments

Comments
 (0)