Skip to content

Commit

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

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

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

Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>

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

This reverts commit 48084a2.

Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Co-authored-by: JesusPoderoso <jesuspoderoso@eprosima.com>
(cherry picked from commit 77768eb)

Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com>
  • Loading branch information
mergify[bot] and Mario-DL authored Jul 31, 2024
1 parent f746b93 commit 45490ae
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 @@ -161,26 +161,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 45490ae

Please sign in to comment.