Skip to content

fix(server): fix http response body resource leak in master controller forwarder#11772

Open
xuezhichao wants to merge 2 commits into
deepflowio:mainfrom
xuezhichao:fix/forward-http-body-leak
Open

fix(server): fix http response body resource leak in master controller forwarder#11772
xuezhichao wants to merge 2 commits into
deepflowio:mainfrom
xuezhichao:fix/forward-http-body-leak

Conversation

@xuezhichao
Copy link
Copy Markdown

Background and Problem / 背景与问题

Chinese:
在多控制器部署架构中,控制器的 HTTP 路由转发模块(ForwardMasterController)负责将 API 请求转发至主控制器。
在当前的实现中,通过 http.DefaultClient.Do(req) 发起 HTTP 请求后,直接将响应体 resp.Body 传递给了 Gin 框架的 c.DataFromReader() 处理:

c.DataFromReader(resp.StatusCode, resp.ContentLength, resp.Header.Get("Content-Type"), resp.Body, make(map[string]string))

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 1, 2026

CLA assistant check
All committers have signed the CLA.

@xuezhichao
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

…r forwarder

In ForwardMasterController, resp.Body is passed to c.DataFromReader()
but is never closed. This causes TCP socket and file descriptor leakage
on master controller API forwarding.

Add defer resp.Body.Close() immediately after Do(req) error checking
to resolve this connection leak.
@xuezhichao xuezhichao force-pushed the fix/forward-http-body-leak branch from 45b22d9 to 10bfd92 Compare June 1, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants