Skip to content

Commit d320038

Browse files
authored
fix: agent panics on closed network (#5295)
* fix: agent panics on closed network * Remove a.network = network * Fix * Fix * Fix
1 parent 061635c commit d320038

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

agent/agent.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ func (a *agent) trackConnGoroutine(fn func()) error {
245245
return nil
246246
}
247247

248-
func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (network *tailnet.Conn, err error) {
248+
func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_ *tailnet.Conn, err error) {
249249
a.closeMutex.Lock()
250250
if a.isClosed() {
251251
a.closeMutex.Unlock()
252252
return nil, xerrors.New("closed")
253253
}
254-
network, err = tailnet.NewConn(&tailnet.Options{
254+
network, err := tailnet.NewConn(&tailnet.Options{
255255
Addresses: []netip.Prefix{netip.PrefixFrom(codersdk.TailnetIP, 128)},
256256
DERPMap: derpMap,
257257
Logger: a.logger.Named("tailnet"),
@@ -266,7 +266,6 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (ne
266266
network.Close()
267267
}
268268
}()
269-
a.network = network
270269
a.closeMutex.Unlock()
271270

272271
sshListener, err := network.Listen("tcp", ":"+strconv.Itoa(codersdk.TailnetSSHPort))

0 commit comments

Comments
 (0)