mirror of
https://github.com/esphome/esphome.git
synced 2026-09-03 19:46:02 +00:00
[esphome.ota] Use existing esphome_lwip_get_sock() instead of adding Socket accessor
get_cached_sock() was a new public method that only OTA's fast-select wake filter would ever call. Drop it. The existing public C API already covers this: esphome_lwip_get_sock(fd) looks up a lwip_sock* from a file descriptor (it's exactly what BSDSocketImpl's own constructor calls to populate cached_sock_). OTA uses the public get_fd() + esphome_lwip_get_sock() chain instead — no new Socket accessor, no friend declarations, no layering concerns. The one-time lookup at setup is negligible.
This commit is contained in:
@@ -78,7 +78,9 @@ void ESPHomeOTAComponent::setup() {
|
||||
// every RCVPLUS across all monitored sockets (API client data, mDNS, etc.) would
|
||||
// pay the inline hook's two volatile stores + memw barriers to mark OTA
|
||||
// pending-enable, even though OTA would just re-disable itself on the next tick.
|
||||
esphome_fast_select_set_ota_listener_sock(this->server_->get_cached_sock());
|
||||
// Uses the existing public esphome_lwip_get_sock() lookup instead of adding a
|
||||
// dedicated accessor on Socket — the lookup happens once at setup, not per event.
|
||||
esphome_fast_select_set_ota_listener_sock(esphome_lwip_get_sock(this->server_->get_fd()));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -118,15 +118,6 @@ class BSDSocketImpl {
|
||||
|
||||
int get_fd() const { return this->fd_; }
|
||||
|
||||
#ifdef USE_LWIP_FAST_SELECT
|
||||
// Cached lwip_sock pointer captured at construction. Used by OTA to register its
|
||||
// listener netconn with the fast-select wake hook filter so the hook only fires on
|
||||
// OTA-relevant events. Returns nullptr for non-monitored sockets.
|
||||
struct lwip_sock *get_cached_sock() const {
|
||||
return this->cached_sock_;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
int fd_{-1};
|
||||
#ifdef USE_LWIP_FAST_SELECT
|
||||
|
||||
@@ -84,13 +84,6 @@ class LwIPSocketImpl {
|
||||
|
||||
int get_fd() const { return this->fd_; }
|
||||
|
||||
#ifdef USE_LWIP_FAST_SELECT
|
||||
// See BSDSocketImpl::get_cached_sock() — same purpose, same semantics.
|
||||
struct lwip_sock *get_cached_sock() const {
|
||||
return this->cached_sock_;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
int fd_{-1};
|
||||
#ifdef USE_LWIP_FAST_SELECT
|
||||
|
||||
Reference in New Issue
Block a user