From 69da17742f509ccdfa69537d4fa770ea93817b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C6=B0u=20Oa=20Oa=20=28=E5=AE=B0=E7=9B=B8=E5=8A=89?= =?UTF-8?q?=E7=BE=85=E9=8D=8B=29?= <212658678+luuoaoa@users.noreply.github.com> Date: Thu, 22 May 2025 09:37:42 -0700 Subject: [PATCH] OTA: Close and clean up client when setsockopt fails (#8865) Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- esphome/components/esphome/ota/ota_esphome.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/components/esphome/ota/ota_esphome.cpp b/esphome/components/esphome/ota/ota_esphome.cpp index 7e2ef42a97..6067da15cb 100644 --- a/esphome/components/esphome/ota/ota_esphome.cpp +++ b/esphome/components/esphome/ota/ota_esphome.cpp @@ -111,6 +111,8 @@ void ESPHomeOTAComponent::handle_() { int err = client_->setsockopt(IPPROTO_TCP, TCP_NODELAY, &enable, sizeof(int)); if (err != 0) { ESP_LOGW(TAG, "Socket could not enable TCP nodelay, errno %d", errno); + client_->close(); + client_ = nullptr; return; }