Skip to content

Commit

Permalink
fix(csysdig): correctly handle progress report on small scap files
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
  • Loading branch information
therealbobo committed Apr 19, 2024
1 parent b553d0c commit e7fe148
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions userspace/sinspui/cursesui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ sinsp_cursesui::sinsp_cursesui(sinsp* inspector,
m_sorting_col = sorting_col;
m_json_spy_renderer = NULL;
m_json_spy_text_fmt = json_spy_text_fmt;
m_n_progress_reports = 0;

#ifndef NOCURSESUI
m_viz = NULL;
Expand Down
16 changes: 9 additions & 7 deletions userspace/sinspui/cursesui.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ class sinsp_cursesui
{
std::string jdata = m_json_spy_renderer->get_data();
double rprogress = m_inspector->get_read_progress();
if(ts > m_1st_evt_ts || next_res == SCAP_EOF)
if(ts > m_1st_evt_ts || (next_res == SCAP_EOF && m_n_progress_reports > 0))
{
// We add the comma only after the first progress status update.
printf(",");
Expand All @@ -646,15 +646,16 @@ class sinsp_cursesui
rprogress,
m_json_spy_renderer->get_count(),
jdata.c_str());
m_n_progress_reports++;

fflush(stdout);
}

if(next_res != SCAP_EOF)
{
// We update the value only if we have
// an event.
m_last_progress_evt = evt->get_num();
}
if(next_res != SCAP_EOF)
{
// We update the value only if we have
// an event.
m_last_progress_evt = evt->get_num();
}

//
Expand Down Expand Up @@ -826,5 +827,6 @@ class sinsp_cursesui
int32_t m_sorting_col;
json_spy_renderer* m_json_spy_renderer;
sinsp_evt::param_fmt m_json_spy_text_fmt;
uint64_t m_n_progress_reports;
};

0 comments on commit e7fe148

Please sign in to comment.