mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: agent panics on closed network (#5295)
* fix: agent panics on closed network * Remove a.network = network * Fix * Fix * Fix
This commit is contained in:
+2
-3
@@ -245,13 +245,13 @@ func (a *agent) trackConnGoroutine(fn func()) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (network *tailnet.Conn, err error) {
|
||||
func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_ *tailnet.Conn, err error) {
|
||||
a.closeMutex.Lock()
|
||||
if a.isClosed() {
|
||||
a.closeMutex.Unlock()
|
||||
return nil, xerrors.New("closed")
|
||||
}
|
||||
network, err = tailnet.NewConn(&tailnet.Options{
|
||||
network, err := tailnet.NewConn(&tailnet.Options{
|
||||
Addresses: []netip.Prefix{netip.PrefixFrom(codersdk.TailnetIP, 128)},
|
||||
DERPMap: derpMap,
|
||||
Logger: a.logger.Named("tailnet"),
|
||||
@@ -266,7 +266,6 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (ne
|
||||
network.Close()
|
||||
}
|
||||
}()
|
||||
a.network = network
|
||||
a.closeMutex.Unlock()
|
||||
|
||||
sshListener, err := network.Listen("tcp", ":"+strconv.Itoa(codersdk.TailnetSSHPort))
|
||||
|
||||
Reference in New Issue
Block a user