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

Commit42e5d71

Browse files
authored
fix: fix closeMutex unlock bug (#17259)
Fixescoder/internal#550Classic return before unlocking bug.
1 parentf6bf6c6 commit42e5d71

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

‎agent/agent.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,14 +1518,11 @@ func (a *agent) runCoordinator(ctx context.Context, tClient tailnetproto.DRPCTai
15181518
a.logger.Info(ctx,"connected to coordination RPC")
15191519

15201520
// This allows the Close() routine to wait for the coordinator to gracefully disconnect.
1521-
a.closeMutex.Lock()
1522-
ifa.isClosed() {
1523-
returnnil
1521+
disconnected:=a.setCoordDisconnected()
1522+
ifdisconnected==nil {
1523+
returnnil// already closed by something else
15241524
}
1525-
disconnected:=make(chanstruct{})
1526-
a.coordDisconnected=disconnected
15271525
deferclose(disconnected)
1528-
a.closeMutex.Unlock()
15291526

15301527
ctrl:=tailnet.NewAgentCoordinationController(a.logger,network)
15311528
coordination:=ctrl.New(coordinate)
@@ -1547,6 +1544,17 @@ func (a *agent) runCoordinator(ctx context.Context, tClient tailnetproto.DRPCTai
15471544
return<-errCh
15481545
}
15491546

1547+
func (a*agent)setCoordDisconnected()chanstruct{} {
1548+
a.closeMutex.Lock()
1549+
defera.closeMutex.Unlock()
1550+
ifa.isClosed() {
1551+
returnnil
1552+
}
1553+
disconnected:=make(chanstruct{})
1554+
a.coordDisconnected=disconnected
1555+
returndisconnected
1556+
}
1557+
15501558
// runDERPMapSubscriber runs a coordinator and returns if a reconnect should occur.
15511559
func (a*agent)runDERPMapSubscriber(ctx context.Context,tClient tailnetproto.DRPCTailnetClient24,network*tailnet.Conn)error {
15521560
defera.logger.Debug(ctx,"disconnected from derp map RPC")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp