[api,ota,captive_portal] Fix fd leaks and clean up socket_ip_loop_monitored setup paths (#14167)

This commit is contained in:
J. Nick Koston
2026-02-20 20:59:49 -06:00
committed by GitHub
parent 0e38acd67a
commit 8589f80d8f
6 changed files with 49 additions and 37 deletions
+8 -1
View File
@@ -249,8 +249,15 @@ class APIServer : public Component,
void add_state_subscription_(std::string entity_id, optional<std::string> attribute,
std::function<void(const std::string &)> f, bool once);
#endif // USE_API_HOMEASSISTANT_STATES
// No explicit close() needed — listen sockets have no active connections on
// failure/shutdown. Destructor handles fd cleanup (close or abort per platform).
inline void destroy_socket_() {
delete this->socket_;
this->socket_ = nullptr;
}
void socket_failed_(const LogString *msg);
// Pointers and pointer-like types first (4 bytes each)
std::unique_ptr<socket::Socket> socket_ = nullptr;
socket::Socket *socket_{nullptr};
#ifdef USE_API_CLIENT_CONNECTED_TRIGGER
Trigger<std::string, std::string> client_connected_trigger_;
#endif