mirror of
https://github.com/tstack/lnav.git
synced 2024-08-16 08:20:29 +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"
|
# include "prqlc.cxx.hh"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace std::literals::chrono_literals;
|
||||||
using namespace lnav::roles::literals;
|
using namespace lnav::roles::literals;
|
||||||
|
|
||||||
exec_context INIT_EXEC_CONTEXT;
|
exec_context INIT_EXEC_CONTEXT;
|
||||||
@ -903,10 +904,12 @@ execute_init_commands(
|
|||||||
}
|
}
|
||||||
|
|
||||||
rescan_files();
|
rescan_files();
|
||||||
auto deadline = current_timeval()
|
auto deadline = ui_clock::now();
|
||||||
+ ((lnav_data.ld_flags & LNF_HEADLESS)
|
if (lnav_data.ld_flags & LNF_HEADLESS) {
|
||||||
? timeval{5, 0}
|
deadline += 5s;
|
||||||
: timeval{0, 500000});
|
} else {
|
||||||
|
deadline += 500ms;
|
||||||
|
}
|
||||||
wait_for_pipers(deadline);
|
wait_for_pipers(deadline);
|
||||||
rebuild_indexes_repeatedly();
|
rebuild_indexes_repeatedly();
|
||||||
}
|
}
|
||||||
|
11
src/lnav.cc
11
src/lnav.cc
@ -867,9 +867,9 @@ gather_pipers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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);
|
auto sleep_time = std::chrono::milliseconds(10);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -879,7 +879,7 @@ wait_for_pipers(std::optional<timeval> deadline)
|
|||||||
log_debug("all pipers finished");
|
log_debug("all pipers finished");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (deadline && (deadline.value() < current_timeval())) {
|
if (deadline && ui_clock::now() > deadline.value()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Use usleep() since it is defined to be interruptable by a signal.
|
// 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)
|
&& lnav_data.ld_active_files.fc_file_names.size() == 1)
|
||||||
{
|
{
|
||||||
rescan_files(true);
|
rescan_files(true);
|
||||||
gather_pipers();
|
wait_for_pipers(ui_clock::now() + 100ms);
|
||||||
auto rebuild_res = rebuild_indexes(ui_clock::now() + 15ms);
|
auto rebuild_res = rebuild_indexes(ui_clock::now() + 15ms);
|
||||||
if (rebuild_res.rir_completed
|
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();
|
rebuild_indexes_repeatedly();
|
||||||
if (lnav_data.ld_active_files.fc_files.empty()
|
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);
|
bool setup_logline_table(exec_context& ec);
|
||||||
void wait_for_children();
|
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
|
#endif
|
||||||
|
@ -70,7 +70,7 @@ rebuild_indexes_repeatedly()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wait_for_pipers(std::optional<timeval>)
|
wait_for_pipers(std::optional<ui_clock::time_point>)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user