- 在上下文取消时正确关闭 lines channel - 防止 goroutine 阻塞导致的内存泄露 - 确保所有资源在程序退出时正确释放
This commit is contained in:
@@ -226,6 +226,7 @@ func processFile(ctx context.Context, logChan *chan string, filePath string, fil
|
|||||||
for i := 0; i < config.APPConfig.ThreadCount; i++ {
|
for i := 0; i < config.APPConfig.ThreadCount; i++ {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
close(lines)
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user