Skip to content

Commit

Permalink
Mitigate LogTests.flush_n flakiness (#5051) (#5063)
Browse files Browse the repository at this point in the history
* Refs #21327: Fix LogTests.flush_n flakiness

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #21327: TODO DROP THIS: add colcon test Dispatch argument

Signed-off-by: JesusPoderoso <[email protected]>

* Revert "Refs #21327: TODO DROP THIS: add colcon test Dispatch argument"

This reverts commit 48084a2.

Signed-off-by: JesusPoderoso <[email protected]>

---------

Signed-off-by: Mario Dominguez <[email protected]>
Signed-off-by: JesusPoderoso <[email protected]>
Co-authored-by: JesusPoderoso <[email protected]>
(cherry picked from commit 77768eb)

Co-authored-by: Mario Domínguez López <[email protected]>
  • Loading branch information
mergify[bot] and Mario-DL authored Jul 15, 2024
1 parent 064ce70 commit edc55d3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/cpp/fastdds/log/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,28 @@ struct LogResources

/* Flush() two steps strategy:
I must assure Log::Run swaps the queues because only swapping the queues the background content
We must assure Log::Run swaps the queues twice
because its the only way the content in the background queue
will be consumed (first Run() loop).
Then, I must assure the new front queue content is consumed (second Run() loop).
Then, we must assure the new front queue content is consumed (second Run() loop).
*/

int last_loop = -1;
int last_loop = current_loop_;

for (int i = 0; i < 2; ++i)
{
cv_.wait(guard,
[&]()
{
/* I must avoid:
+ the two calls be processed without an intermediate Run() loop (by using last_loop sequence number)
/* We must avoid:
+ the two calls be processed without an intermediate Run() loop
(by using last_loop sequence number and checking if the foreground queue is empty)
+ deadlock by absence of Run() loop activity (by using BothEmpty() call)
*/
return !logging_ ||
(logs_.Empty() &&
(last_loop != current_loop_ || logs_.BothEmpty()));
logs_.BothEmpty() ||
(last_loop != current_loop_ && logs_.Empty());
});

last_loop = current_loop_;
Expand Down

0 comments on commit edc55d3

Please sign in to comment.