init: periodic state updates if sensible

Under certain circumstances we don't want inits state report to become too
outdated even if there is no change to its config or the sessions of its
children. This is the case if init is requested to provide a capability or RAM
info of it's children via its state report. Now, init automatically updates
the state report with each 1000 ms if the attribute 'child_caps' or
'child_ram' is positively set in the 'report' tag.
This commit is contained in:
Martin Stein 2017-10-25 16:34:52 +02:00 committed by Christian Helmuth
parent 3409eeeb34
commit 615878bb05
1 changed files with 16 additions and 0 deletions

View File

@ -52,10 +52,14 @@ class Init::State_reporter : public Report_update_trigger
Version _version;
Constructible<Timer::Connection> _timer;
Constructible<Timer::Connection> _timer_periodic;
Signal_handler<State_reporter> _timer_handler {
_env.ep(), *this, &State_reporter::_handle_timer };
Signal_handler<State_reporter> _timer_periodic_handler {
_env.ep(), *this, &State_reporter::_handle_timer };
bool _scheduled = false;
void _handle_timer()
@ -134,6 +138,18 @@ class Init::State_reporter : public Report_update_trigger
if (trigger_update)
trigger_report_update();
if (_report_detail->child_ram() || _report_detail->child_caps()) {
if (!_timer_periodic.constructed()) {
_timer_periodic.construct(_env);
_timer_periodic->sigh(_timer_periodic_handler);
}
_timer_periodic->trigger_periodic(1000*1000);
} else {
if (_timer_periodic.constructed()) {
_timer_periodic.destruct();
}
}
}
void trigger_report_update() override