mirror of
https://github.com/tstack/lnav.git
synced 2024-08-16 16:30:25 +03:00
[pager] try to fix the check for switching to headless
This commit is contained in:
parent
4759a59b23
commit
3fdf710dfd
@ -59,6 +59,7 @@
|
||||
# include "prqlc.cxx.hh"
|
||||
#endif
|
||||
|
||||
using namespace std::literals::chrono_literals;
|
||||
using namespace lnav::roles::literals;
|
||||
|
||||
exec_context INIT_EXEC_CONTEXT;
|
||||
@ -903,10 +904,12 @@ execute_init_commands(
|
||||
}
|
||||
|
||||
rescan_files();
|
||||
auto deadline = current_timeval()
|
||||
+ ((lnav_data.ld_flags & LNF_HEADLESS)
|
||||
? timeval{5, 0}
|
||||
: timeval{0, 500000});
|
||||
auto deadline = ui_clock::now();
|
||||
if (lnav_data.ld_flags & LNF_HEADLESS) {
|
||||
deadline += 5s;
|
||||
} else {
|
||||
deadline += 500ms;
|
||||
}
|
||||
wait_for_pipers(deadline);
|
||||
rebuild_indexes_repeatedly();
|
||||
}
|
||||
|
11
src/lnav.cc
11
src/lnav.cc
@ -867,9 +867,9 @@ gather_pipers()
|
||||
}
|
||||
|
||||
void
|
||||
wait_for_pipers(std::optional<timeval> deadline)
|
||||
wait_for_pipers(std::optional<ui_clock::time_point> deadline)
|
||||
{
|
||||
static const auto MAX_SLEEP_TIME = std::chrono::milliseconds(300);
|
||||
static constexpr auto MAX_SLEEP_TIME = std::chrono::milliseconds(300);
|
||||
auto sleep_time = std::chrono::milliseconds(10);
|
||||
|
||||
for (;;) {
|
||||
@ -879,7 +879,7 @@ wait_for_pipers(std::optional<timeval> deadline)
|
||||
log_debug("all pipers finished");
|
||||
break;
|
||||
}
|
||||
if (deadline && (deadline.value() < current_timeval())) {
|
||||
if (deadline && ui_clock::now() > deadline.value()) {
|
||||
break;
|
||||
}
|
||||
// Use usleep() since it is defined to be interruptable by a signal.
|
||||
@ -3340,10 +3340,11 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
|
||||
&& lnav_data.ld_active_files.fc_file_names.size() == 1)
|
||||
{
|
||||
rescan_files(true);
|
||||
gather_pipers();
|
||||
wait_for_pipers(ui_clock::now() + 100ms);
|
||||
auto rebuild_res = rebuild_indexes(ui_clock::now() + 15ms);
|
||||
if (rebuild_res.rir_completed
|
||||
&& lnav_data.ld_child_pollers.empty())
|
||||
&& lnav_data.ld_child_pollers.empty()
|
||||
&& lnav_data.ld_active_files.active_pipers() == 0)
|
||||
{
|
||||
rebuild_indexes_repeatedly();
|
||||
if (lnav_data.ld_active_files.fc_files.empty()
|
||||
|
@ -293,6 +293,7 @@ extern const ssize_t ZOOM_COUNT;
|
||||
|
||||
bool setup_logline_table(exec_context& ec);
|
||||
void wait_for_children();
|
||||
void wait_for_pipers(std::optional<timeval> deadline = std::nullopt);
|
||||
void wait_for_pipers(std::optional<ui_clock::time_point> deadline
|
||||
= std::nullopt);
|
||||
|
||||
#endif
|
||||
|
@ -70,7 +70,7 @@ rebuild_indexes_repeatedly()
|
||||
}
|
||||
|
||||
void
|
||||
wait_for_pipers(std::optional<timeval>)
|
||||
wait_for_pipers(std::optional<ui_clock::time_point>)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user