Skip to content

Commit dd0dd4e

Browse files
committed
squash, tox_iteration_interval(...) must be inside lock
1 parent 375062d commit dd0dd4e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

auto_tests/toxav_mt_test.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ class AV_State {
264264

265265
void tox_iterator() {
266266
while (!stop_threads_.load()) {
267+
uint32_t sleep_ms = 0;
268+
267269
// Perform this block only while loop lock is held
268270
{
269271
std::lock_guard<std::mutex> lock(tox_loop_lock_);
@@ -310,9 +312,12 @@ class AV_State {
310312
in_call_.store(false);
311313
}
312314
}
315+
316+
// WARNING: This accesses the Tox struct, so it must be inside the lock
317+
tox_iteration_interval(tox_.get());
313318
}
314319

315-
std::this_thread::sleep_for(std::chrono::milliseconds(tox_iteration_interval(tox_.get())));
320+
std::this_thread::sleep_for(std::chrono::milliseconds(sleep_ms));
316321
}
317322
}
318323

0 commit comments

Comments
 (0)