Address review comments: clarify socket type comments, use log helper for reuseaddr

This commit is contained in:
J. Nick Koston
2026-02-20 18:06:38 -06:00
parent 7a6df910e5
commit f389314945
3 changed files with 4 additions and 4 deletions

View File

@@ -249,7 +249,7 @@ 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
// Socket destructor calls close() if not already closed
// Listen sockets use LwIPSocketImpl/BSDSocketImpl whose destructors call close()
inline void close_socket_() {
delete this->socket_;
this->socket_ = nullptr;

View File

@@ -14,7 +14,7 @@ class DNSServer {
void process_next_request();
protected:
// Socket destructor calls close() if not already closed
// Listen sockets use LwIPSocketImpl/BSDSocketImpl whose destructors call close()
inline void close_socket_() {
delete this->socket_;
this->socket_ = nullptr;

View File

@@ -36,7 +36,7 @@ void ESPHomeOTAComponent::setup() {
int enable = 1;
int err = this->server_->setsockopt(SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int));
if (err != 0) {
ESP_LOGW(TAG, "Socket reuseaddr: errno %d", errno);
this->log_socket_error_(LOG_STR("reuseaddr"));
// we can still continue
}
err = this->server_->setblocking(false);
@@ -452,7 +452,7 @@ void ESPHomeOTAComponent::log_remote_closed_(const LogString *during) {
void ESPHomeOTAComponent::server_failed_(const LogString *msg) {
this->log_socket_error_(msg);
// Socket destructor calls close() if not already closed
// Listen sockets use LwIPSocketImpl/BSDSocketImpl whose destructors call close()
delete this->server_;
this->server_ = nullptr;
this->mark_failed();