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

fix(userspace/libsinsp): do not immediately process async events whose timestamp is in the future in case a SCAP_TIMEOUT is received #2250

Merged
merged 1 commit into from
Jan 31, 2025
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
14 changes: 8 additions & 6 deletions userspace/libsinsp/sinsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,13 +1137,15 @@
// error is encountered) we attempt popping an event from the asynchronous
// event queue. If none is available, we just return the timeout.
// note: the queue is optimized for checking for emptyness before popping
if(res == SCAP_TIMEOUT && !m_async_events_queue.empty() &&
m_async_events_queue.try_pop(m_async_evt)) {
evt = m_async_evt.get();
if(evt->get_scap_evt()->ts == (uint64_t)-1) {
evt->get_scap_evt()->ts = get_new_ts();
if(res == SCAP_TIMEOUT && !m_async_events_queue.empty()) {
m_async_events_checker.ts = get_new_ts();
if(m_async_events_queue.try_pop_if(m_async_evt, m_async_events_checker)) {
evt = m_async_evt.get();
if(evt->get_scap_evt()->ts == (uint64_t)-1) {
evt->get_scap_evt()->ts = get_new_ts();
}
return SCAP_SUCCESS;

Check warning on line 1147 in userspace/libsinsp/sinsp.cpp

View check run for this annotation

Codecov / codecov/patch

userspace/libsinsp/sinsp.cpp#L1147

Added line #L1147 was not covered by tests
}
return SCAP_SUCCESS;
}

// in case we successfully fetched an event, or we have one delayed from
Expand Down
Loading