[PR #4638] [MERGED] 解决goroutine泄漏问题 #5015

Closed
opened 2026-05-05 14:53:06 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/4638
Author: @Alpha2J
Created: 1/15/2025
Status: Merged
Merged: 1/16/2025
Merged by: @fatedier

Base: devHead: fix/goroutine_leaks


📝 Commits (3)

📊 Changes

1 file changed (+7 additions, -6 deletions)

View changed files

📝 server/proxy/xtcp.go (+7 -6)

📄 Description

WHY

由于closeCh没有被初始化,在Close()函数中执行close(pxy.closeCh)的时候,会panic:"panic error: close of nil channel";导致无法退出Run()函数中创建的goroutine,造成goroutine泄漏,同时引发内存泄漏;在我的案例中,client用户单实例大概4000,运行两天,阻塞在case <-pxy.closeCh中的goroutine达到三万多;


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fatedier/frp/pull/4638 **Author:** [@Alpha2J](https://github.com/Alpha2J) **Created:** 1/15/2025 **Status:** ✅ Merged **Merged:** 1/16/2025 **Merged by:** [@fatedier](https://github.com/fatedier) **Base:** `dev` ← **Head:** `fix/goroutine_leaks` --- ### 📝 Commits (3) - [`93289aa`](https://github.com/fatedier/frp/commit/93289aab032745125297c735ce4dac9a59b40367) Fix goroutine leaks - [`881f214`](https://github.com/fatedier/frp/commit/881f21431d312885d54bd471e8849eabce6216b0) Fix goroutine leaks - [`751c789`](https://github.com/fatedier/frp/commit/751c789cca6039f79a04a1b3a9e2e17fa795c7b3) Fix goroutine leaks ### 📊 Changes **1 file changed** (+7 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `server/proxy/xtcp.go` (+7 -6) </details> ### 📄 Description ### WHY 由于`closeCh`没有被初始化,在`Close()`函数中执行`close(pxy.closeCh)`的时候,会panic:"panic error: close of nil channel";导致无法退出`Run()`函数中创建的goroutine,造成goroutine泄漏,同时引发内存泄漏;在我的案例中,client用户单实例大概4000,运行两天,阻塞在`case <-pxy.closeCh`中的goroutine达到三万多; --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 14:53:06 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#5015
No description provided.