mirror of
https://github.com/esphome/esphome.git
synced 2026-09-30 08:20:21 +00:00
[socket] Dedupe fast_select hook logic into shared helper
Lift the lwip_sock resolve + event-callback hook sequence into socket::fast_select_hook_fd() in socket.h so the USE_LWIP_FAST_SELECT constructor blocks in lwip_sockets_impl.cpp and bsd_sockets_impl.cpp stop drifting in lockstep. Both impls now collapse to a two-line call site.
This commit is contained in:
@@ -14,13 +14,8 @@ BSDSocketImpl::BSDSocketImpl(int fd, bool monitor_loop) {
|
||||
if (!monitor_loop || this->fd_ < 0)
|
||||
return;
|
||||
#ifdef USE_LWIP_FAST_SELECT
|
||||
// Cache lwip_sock pointer (used by ready() for direct rcvevent reads) and hook the
|
||||
// netconn event callback so the main loop is notified via FreeRTOS task notifications.
|
||||
this->cached_sock_ = esphome_lwip_get_sock(this->fd_);
|
||||
if (this->cached_sock_ != nullptr) {
|
||||
esphome_lwip_hook_socket(this->cached_sock_);
|
||||
this->loop_monitored_ = true;
|
||||
}
|
||||
this->cached_sock_ = fast_select_hook_fd(this->fd_);
|
||||
this->loop_monitored_ = this->cached_sock_ != nullptr;
|
||||
#else
|
||||
this->loop_monitored_ = App.register_socket_fd(this->fd_);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user