mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #3860] panic: close of closed channel #3068
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#3068
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @itning on GitHub (Dec 19, 2023).
Original GitHub issue: https://github.com/fatedier/frp/issues/3860
Bug Description
frpc Version
0.53.0
frps Version
0.53.0
System Architecture
linux/amd64
Configurations
N/A
Logs
No response
Steps to reproduce
I don` know.
Affected area
@fatedier commented on GitHub (Dec 19, 2023):
Please provide as complete as possible the content of the log before.
@itning commented on GitHub (Dec 19, 2023):
no more info for logs.

@im-zhou commented on GitHub (Dec 20, 2023):
Code
经测试
loopLoginUntilSuccess有几率触发重复登录(即显示两次login successful, 相同 runid), 造成panic ̊ଳ ̊ᵎᵎᵎᵎ@fatedier commented on GitHub (Dec 20, 2023):
@im-zhou 你如果懂代码的话,可以看一下怎么复现和修复。修复比较简单,通过 sync.Once 可以确保只 close 一次,主要是找到原因,从根本上解决。
@alvinkwok1 commented on GitHub (Dec 20, 2023):
我也遇到了同样的问题。我的设备是ubuntu22.04上的,我采用的systemd的形式启动的只有这样才会有问题,如果是直接命令启动没有这个毛病。
@wuqinqiang commented on GitHub (Dec 21, 2023):
粗略看了一下, 问题的关键是BackoffUntil 的逻辑 无法保证 ticker 触发时机和 对stopCh 信号接收的先后关系,可能stopCh 关闭的同时本轮已经开始走了,导致会多次调用相同的f,直到n轮的时候被检测然后才return
@wuqinqiang commented on GitHub (Dec 21, 2023):
我觉得Backoff应该新增一个函数,区别心跳这种heartbeatWorker成功了也需要继续的逻辑,以及像login 这样的只要成功直接能退出的 @fatedier
@z357904947 commented on GitHub (Dec 21, 2023):
我使用0.53的版本,在客户端启动的时候也出现了个错误
@im-zhou commented on GitHub (Dec 21, 2023):
是否可以这样优化:
不理会
stopCh, 只要首次loginFunc登录成功,就退出测试几轮貌似没什么问题 :xd:
@fatedier commented on GitHub (Dec 21, 2023):
@im-zhou @wuqinqiang 我觉得可以考虑扩展执行函数的返回值,从
f func() error变更为f func() (done bool, err error)。由传入函数的返回决定是否需要立即退出,done 为 true 时,表示无需再继续执行。
@wuqinqiang commented on GitHub (Dec 21, 2023):
这样没问额
但是我觉得扩展BackoffUntil(f func() error, backoff BackoffManager, sliding bool, stopCh <-chan struct{},options ...opt) 代价更小,至少api不会发生变化
另外正好请教一下,
https://github.com/fatedier/frp/blob/dev/pkg/util/wait/backoff.go#L130
https://github.com/fatedier/frp/blob/dev/pkg/util/wait/backoff.go#L140
这里为啥这样写,我没看懂,sliding的值不会改变, 感觉是逻辑bug
@fatedier commented on GitHub (Dec 21, 2023):
@wuqinqiang 同一个函数的参数有多个控制 stop 的语义,会有一点奇怪,另外不太倾向于入参里增加太多的参数,会让一个简单的函数变得越来越复杂,调用的心智负担会很重。
sliding 是额外考虑函数执行时间,一个是包括了函数执行耗时,一个是不包括。