Skip to content
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

[21327] Mitigate LogTests.flush_n flakiness #5051

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/cpp/fastdds/log/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,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
Loading