Skip to content

Commit e009e25

Browse files
Mario-DLJesusPoderoso
authored andcommitted
Mitigate LogTests.flush_n flakiness (#5051)
* 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)
1 parent 9ddd1af commit e009e25

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/cpp/fastdds/log/Log.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,26 +174,28 @@ struct LogResources
174174

175175
/* Flush() two steps strategy:
176176
177-
I must assure Log::Run swaps the queues because only swapping the queues the background content
177+
We must assure Log::Run swaps the queues twice
178+
because its the only way the content in the background queue
178179
will be consumed (first Run() loop).
179180
180-
Then, I must assure the new front queue content is consumed (second Run() loop).
181+
Then, we must assure the new front queue content is consumed (second Run() loop).
181182
*/
182183

183-
int last_loop = -1;
184+
int last_loop = current_loop_;
184185

185186
for (int i = 0; i < 2; ++i)
186187
{
187188
cv_.wait(guard,
188189
[&]()
189190
{
190-
/* I must avoid:
191-
+ the two calls be processed without an intermediate Run() loop (by using last_loop sequence number)
191+
/* We must avoid:
192+
+ the two calls be processed without an intermediate Run() loop
193+
(by using last_loop sequence number and checking if the foreground queue is empty)
192194
+ deadlock by absence of Run() loop activity (by using BothEmpty() call)
193195
*/
194196
return !logging_ ||
195-
(logs_.Empty() &&
196-
(last_loop != current_loop_ || logs_.BothEmpty()));
197+
logs_.BothEmpty() ||
198+
(last_loop != current_loop_ && logs_.Empty());
197199
});
198200

199201
last_loop = current_loop_;

0 commit comments

Comments
 (0)