Skip to content

Commit

Permalink
fix(libsinsp-e2e-tests): concurrency
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Guerra <[email protected]>
  • Loading branch information
LucaGuerra authored and poiana committed Sep 25, 2024
1 parent 9b4a0d2 commit f87b40f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions test/libsinsp_e2e/event_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ void event_capture::capture() {
sinsp_evt* event;
bool result = true;
int32_t next_result = SCAP_SUCCESS;
while(!m_capture_stopped && result && !::testing::Test::HasFatalFailure()) {
while(result && !::testing::Test::HasFatalFailure()) {
{
std::lock_guard<std::mutex> lock(m_object_state_mutex);
if(m_capture_stopped) {
break;
}
}
{
std::scoped_lock inspector_next_lock(m_inspector_mutex);
next_result = get_inspector()->next(&event);
Expand All @@ -120,7 +126,10 @@ void event_capture::capture() {
}
if(!signaled_start) {
signaled_start = true;
m_capture_started = true;
{
std::lock_guard<std::mutex> lock(m_object_state_mutex);
m_capture_started = true;
}
m_condition_started.notify_one();
}
}
Expand Down Expand Up @@ -171,8 +180,9 @@ void event_capture::capture() {
}

m_capture_stopped = true;
m_condition_stopped.notify_one();
} // End teardown synchronized section

m_condition_stopped.notify_one();
}

void event_capture::stop_capture() {
Expand Down

0 comments on commit f87b40f

Please sign in to comment.