mirror of
https://github.com/pion/ice.git
synced 2025-10-16 04:20:41 +08:00
Don't allocate new error inside TaskLoop
Libraries use errors.Is to catch this error. Allocating a new one inside internal breaks that
This commit is contained in:
@@ -13,8 +13,8 @@ import (
|
||||
atomicx "github.com/pion/ice/v3/internal/atomic"
|
||||
)
|
||||
|
||||
// errClosed indicates that the loop has been stopped
|
||||
var errClosed = errors.New("the agent is closed")
|
||||
// ErrClosed indicates that the loop has been stopped
|
||||
var ErrClosed = errors.New("the agent is closed")
|
||||
|
||||
type task struct {
|
||||
fn func(context.Context)
|
||||
@@ -68,7 +68,7 @@ func (l *Loop) Close() error {
|
||||
return err
|
||||
}
|
||||
|
||||
l.err.Store(errClosed)
|
||||
l.err.Store(ErrClosed)
|
||||
|
||||
close(l.done)
|
||||
<-l.taskLoopDone
|
||||
@@ -104,7 +104,7 @@ func (l *Loop) Done() <-chan struct{} {
|
||||
func (l *Loop) Err() error {
|
||||
select {
|
||||
case <-l.done:
|
||||
return errClosed
|
||||
return ErrClosed
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user