mirror of
https://github.com/esphome/esphome.git
synced 2025-08-01 16:07:47 +00:00
[scheduler] Fix crash with defer
This commit is contained in:
parent
0ffc446315
commit
9946592196
@ -1,13 +1,13 @@
|
|||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <cstring>
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
#include "esphome/core/defines.h"
|
#include "esphome/core/defines.h"
|
||||||
#include "esphome/core/hal.h"
|
#include "esphome/core/hal.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include <algorithm>
|
|
||||||
#include <cinttypes>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
||||||
@ -86,8 +86,10 @@ void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type
|
|||||||
// ESP8266 and RP2040 are excluded because they don't need thread-safe defer handling
|
// ESP8266 and RP2040 are excluded because they don't need thread-safe defer handling
|
||||||
if (delay == 0 && type == SchedulerItem::TIMEOUT) {
|
if (delay == 0 && type == SchedulerItem::TIMEOUT) {
|
||||||
// Put in defer queue for guaranteed FIFO execution
|
// Put in defer queue for guaranteed FIFO execution
|
||||||
LockGuard guard{this->lock_};
|
if (is_name_valid_(name_cstr)) {
|
||||||
this->cancel_item_locked_(component, name_cstr, type);
|
LockGuard guard{this->lock_};
|
||||||
|
this->cancel_item_locked_(component, name_cstr, type);
|
||||||
|
}
|
||||||
this->defer_queue_.push_back(std::move(item));
|
this->defer_queue_.push_back(std::move(item));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user