Skip to content

Commit

Permalink
[power-udev] do not start i/o when dumping metadata
Browse files Browse the repository at this point in the history
When provider is loaded under qemu, there is exception on provider loading
because netlink is not supported

Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
  • Loading branch information
Denis Zalevskiy committed Feb 24, 2015
1 parent d511f2e commit ff1ce81
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rpm/statefs-providers.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
%define maemo_ver1 0.7.31
%define meego_ver 0.1.0
%define meego_ver1 0.1.0.1
%define statefs_ver 0.3.28
%define statefs_ver 0.3.28.1

Summary: Statefs providers
Name: statefs-providers
Expand Down
2 changes: 1 addition & 1 deletion rpm/statefs-providers.spec.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
%define maemo_ver1 0.7.31
%define meego_ver 0.1.0
%define meego_ver1 0.1.0.1
%define statefs_ver 0.3.28
%define statefs_ver 0.3.28.1

Summary: Statefs providers
Name: statefs-providers
Expand Down
13 changes: 8 additions & 5 deletions src/power_udev/provider_power_udev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,8 @@ class Provider : public statefs::AProvider
Provider(statefs_server *server)
: AProvider("udev", server)
{
auto ns = std::make_shared<BatteryNs>();
auto ns = std::make_shared<BatteryNs>
(server ? server->mode : statefs_provider_mode_run);
insert(std::static_pointer_cast<statefs::ANode>(ns));
}
virtual ~Provider() {}
Expand Down Expand Up @@ -887,9 +888,9 @@ void BatteryInfo::on_charging_changed(ChargingState)
denergy_.clear();
}

BatteryNs::BatteryNs()
BatteryNs::BatteryNs(statefs_provider_mode mode)
: Namespace("Battery")
, mon_(new Monitor(io_, this))
, mon_(mode == statefs_provider_mode_run ? new Monitor(io_, this) : nullptr)
, analog_info_{{
// BatteryNs::Prop::Temperature, mon_->temperature_source()
}}
Expand All @@ -916,8 +917,10 @@ BatteryNs::BatteryNs()
*this << prop;
}
}
mon_->run();
monitor_thread_ = cor::make_unique<std::thread>([this]() { io_.run(); });
if (mon_) {
mon_->run();
monitor_thread_ = cor::make_unique<std::thread>([this]() { io_.run(); });
}
}

void BatteryNs::set(Prop id, std::string const &v)
Expand Down

0 comments on commit ff1ce81

Please sign in to comment.