mirror of
https://github.com/esphome/esphome.git
synced 2026-03-02 18:58:20 -07:00
Address review comments: clarify socket type comments, use log helper for reuseaddr
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user