fix(webui): check_port_available: enable SO_REUSEADDR option

Allow binding in TIME_WAIT state to reduce false positives (occurs when app restarts).
pull/1511/head
undefined 2026-02-16 15:46:40 +08:00 committed by GitHub
parent b63b7a7fb9
commit e62c221192
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View File

@ -89,6 +89,8 @@ class WebUIServer:
try:
with socket.socket(family, socket.SOCK_STREAM) as s:
s.settimeout(1)
# 与 Uvicorn 一致:允许在 TIME_WAIT 状态下绑定,减少误报
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# 尝试绑定端口
s.bind((test_host, self.port))
return True