Skip to content

Commit 45490ae

Browse files
Mitigate LogTests.flush_n flakiness (#5051) (#5064)
* 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]>
1 parent f746b93 commit 45490ae

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
@@ -161,26 +161,28 @@ struct LogResources
161161

162162
/* Flush() two steps strategy:
163163
164-
I must assure Log::Run swaps the queues because only swapping the queues the background content
164+
We must assure Log::Run swaps the queues twice
165+
because its the only way the content in the background queue
165166
will be consumed (first Run() loop).
166167
167-
Then, I must assure the new front queue content is consumed (second Run() loop).
168+
Then, we must assure the new front queue content is consumed (second Run() loop).
168169
*/
169170

170-
int last_loop = -1;
171+
int last_loop = current_loop_;
171172

172173
for (int i = 0; i < 2; ++i)
173174
{
174175
cv_.wait(guard,
175176
[&]()
176177
{
177-
/* I must avoid:
178-
+ the two calls be processed without an intermediate Run() loop (by using last_loop sequence number)
178+
/* We must avoid:
179+
+ the two calls be processed without an intermediate Run() loop
180+
(by using last_loop sequence number and checking if the foreground queue is empty)
179181
+ deadlock by absence of Run() loop activity (by using BothEmpty() call)
180182
*/
181183
return !logging_ ||
182-
(logs_.Empty() &&
183-
(last_loop != current_loop_ || logs_.BothEmpty()));
184+
logs_.BothEmpty() ||
185+
(last_loop != current_loop_ && logs_.Empty());
184186
});
185187

186188
last_loop = current_loop_;

0 commit comments

Comments
 (0)