Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita117d75

Browse files
committed
Fix close listener func
1 parent5e7197c commita117d75

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎tailnet/conn.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ func NewConn(options *Options) (*Conn, error) {
187187
logIPs,_:=logIPSet.IPSet()
188188
wireguardEngine.SetFilter(filter.New(netMap.PacketFilter,localIPs,logIPs,nil,Logger(options.Logger.Named("packet-filter"))))
189189
server:=&Conn{
190+
closed:make(chanstruct{}),
190191
logger:options.Logger,
191192
magicConn:magicConn,
192193
dialer:dialer,
@@ -335,22 +336,22 @@ func (c *Conn) Ping(ip netip.Addr, pingType tailcfg.PingType, cb func(*ipnstate.
335336

336337
// Closed is a channel that ends when the connection has
337338
// been closed.
338-
func (c*Conn)Closed()chan<-struct{} {
339+
func (c*Conn)Closed()<-chanstruct{} {
339340
returnc.closed
340341
}
341342

342343
// Close shuts down the Wireguard connection.
343344
func (c*Conn)Close()error {
344-
for_,l:=rangec.listeners {
345-
_=l.Close()
346-
}
347345
c.mutex.Lock()
348346
deferc.mutex.Unlock()
349347
select {
350348
case<-c.closed:
351349
returnnil
352350
default:
353351
}
352+
for_,l:=rangec.listeners {
353+
_=l.closeNoLock()
354+
}
354355
close(c.closed)
355356
_=c.dialer.Close()
356357
_=c.magicConn.Close()
@@ -454,6 +455,10 @@ func (ln *listener) Addr() net.Addr { return addr{ln} }
454455
func (ln*listener)Close()error {
455456
ln.s.mutex.Lock()
456457
deferln.s.mutex.Unlock()
458+
returnln.closeNoLock()
459+
}
460+
461+
func (ln*listener)closeNoLock()error {
457462
ifv,ok:=ln.s.listeners[ln.key];ok&&v==ln {
458463
delete(ln.s.listeners,ln.key)
459464
close(ln.conn)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp