Fix: move battery's lock_guard to updateSettings() (#566)
the updateSettings method is called from the web server's context and therefore accesses _upProvider in a different context than the TaskScheduler. the lock_guard needs to protect _upProvider.
This commit is contained in:
parent
6ab706c87d
commit
d769cdd30a
@ -26,13 +26,14 @@ void BatteryClass::init(Scheduler& scheduler)
|
|||||||
_loopTask.setCallback(std::bind(&BatteryClass::loop, this));
|
_loopTask.setCallback(std::bind(&BatteryClass::loop, this));
|
||||||
_loopTask.setIterations(TASK_FOREVER);
|
_loopTask.setIterations(TASK_FOREVER);
|
||||||
_loopTask.enable();
|
_loopTask.enable();
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
|
||||||
|
|
||||||
this->updateSettings();
|
this->updateSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatteryClass::updateSettings()
|
void BatteryClass::updateSettings()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
|
||||||
if (_upProvider) {
|
if (_upProvider) {
|
||||||
_upProvider->deinit();
|
_upProvider->deinit();
|
||||||
_upProvider = nullptr;
|
_upProvider = nullptr;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user