Skip to content

Commit

Permalink
修复外部上下文关闭,连接没有断开的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
injoyai committed May 23, 2024
1 parent d24c8ff commit f367e8e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions io_client_closer.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ func (this *Client) timer(ctx context.Context, dealErr func(error) error, interv
func (this *Client) For(fn func(ctx context.Context) error) (err error) {
for {
select {
case <-this.DoneAll():
//1. 调用了CloseAll方法进行关闭
//2. 通过外部的上下文Cancel进行关闭,需要进行断开连接操作
this.CloseAll()
return this.Err()
case <-this.Done():
//1. 调用了Close方法
//2. 连接报错触发了Close
return this.Err()
default:
_ = this.CloseWithErr(func() (err error) {
Expand Down

0 comments on commit f367e8e

Please sign in to comment.