@@ -219,7 +219,7 @@ type urlTestGroup struct {
219219 pauseCallback * list.Element [pause.Callback ]
220220 logger log.Logger
221221 tags []string
222- outbounds * isync.TypedMap [string , A.Outbound ]
222+ outbounds isync.TypedMap [string , A.Outbound ]
223223 link string
224224 interval time.Duration
225225 tolerance uint16
@@ -262,7 +262,7 @@ func (g *urlTestGroup) Start() error {
262262 g .history = urltest .NewHistoryStorage ()
263263 }
264264 g .pauseMgr = service.FromContext [pause.Manager ](g .ctx )
265- g .stop = make (chan struct {})
265+ g .stop = make (chan struct {}, 1 )
266266 return nil
267267}
268268
@@ -280,9 +280,11 @@ func (g *urlTestGroup) Close() error {
280280 if g .isClosed () {
281281 return nil
282282 }
283- g .ticker .Stop ()
284- g .idleTimer .Stop ()
285- g .pauseMgr .UnregisterCallback (g .pauseCallback )
283+ if g .ticker != nil {
284+ g .ticker .Stop ()
285+ g .idleTimer .Stop ()
286+ g .pauseMgr .UnregisterCallback (g .pauseCallback )
287+ }
286288 close (g .stop )
287289 return nil
288290}
@@ -341,10 +343,11 @@ func (g *urlTestGroup) Remove(tags []string) (n int, err error) {
341343 for tag := range g .outbounds .Iter () {
342344 g .tags = append (g .tags , tag )
343345 }
344- if len (g .tags ) == 0 {
345- g .stop <- struct {}{}
346- g .selectedOutboundTCP .Store (nil )
347- g .selectedOutboundUDP .Store (nil )
346+ if len (g .tags ) == 0 && g .running .Load () {
347+ select {
348+ case g .stop <- struct {}{}:
349+ default :
350+ }
348351 }
349352 g .updateSelected ()
350353 return
@@ -404,6 +407,9 @@ func (g *urlTestGroup) urlTest(ctx context.Context, force bool) (map[string]uint
404407 if g .checking .Swap (true ) {
405408 return result , nil
406409 }
410+ if len (g .tags ) == 0 {
411+ return result , nil
412+ }
407413 defer g .checking .Store (false )
408414 b , _ := batch .New (ctx , batch.WithConcurrencyNum [any ](10 ))
409415 checked := make (map [string ]bool )
@@ -448,6 +454,11 @@ func (g *urlTestGroup) urlTest(ctx context.Context, force bool) (map[string]uint
448454}
449455
450456func (g * urlTestGroup ) updateSelected () {
457+ if len (g .tags ) == 0 {
458+ g .selectedOutboundTCP .Store (nil )
459+ g .selectedOutboundUDP .Store (nil )
460+ return
461+ }
451462 tcpOutbound := g .selectedOutboundTCP .Load ()
452463 if outbound := g .pickBestOutbound ("tcp" , tcpOutbound ); outbound != tcpOutbound {
453464 g .selectedOutboundTCP .Store (outbound )
0 commit comments