Skip to content

Commit 8482346

Browse files
committed
Fix vscode configs test
1 parent ee535a0 commit 8482346

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

agent/agent.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,13 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (*t
226226
a.closeMutex.Unlock()
227227
return nil, xerrors.New("closed")
228228
}
229-
a.connCloseWait.Add(1)
230-
a.closeMutex.Unlock()
231229
network, err := tailnet.NewConn(&tailnet.Options{
232230
Addresses: []netip.Prefix{netip.PrefixFrom(codersdk.TailnetIP, 128)},
233231
DERPMap: derpMap,
234232
Logger: a.logger.Named("tailnet"),
235233
})
236234
if err != nil {
235+
a.closeMutex.Unlock()
237236
return nil, xerrors.Errorf("create tailnet: %w", err)
238237
}
239238
a.network = network
@@ -244,6 +243,8 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (*t
244243
}
245244
return a.stats.wrapConn(conn)
246245
})
246+
a.connCloseWait.Add(4)
247+
a.closeMutex.Unlock()
247248

248249
sshListener, err := network.Listen("tcp", ":"+strconv.Itoa(codersdk.TailnetSSHPort))
249250
if err != nil {
@@ -264,9 +265,6 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (*t
264265
if err != nil {
265266
return nil, xerrors.Errorf("listen for reconnecting pty: %w", err)
266267
}
267-
a.closeMutex.Lock()
268-
a.connCloseWait.Add(1)
269-
a.closeMutex.Unlock()
270268
go func() {
271269
defer a.connCloseWait.Done()
272270
for {
@@ -302,9 +300,6 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (*t
302300
if err != nil {
303301
return nil, xerrors.Errorf("listen for speedtest: %w", err)
304302
}
305-
a.closeMutex.Lock()
306-
a.connCloseWait.Add(1)
307-
a.closeMutex.Unlock()
308303
go func() {
309304
defer a.connCloseWait.Done()
310305
for {
@@ -327,9 +322,6 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (*t
327322
if err != nil {
328323
return nil, xerrors.Errorf("listen for statistics: %w", err)
329324
}
330-
a.closeMutex.Lock()
331-
a.connCloseWait.Add(1)
332-
a.closeMutex.Unlock()
333325
go func() {
334326
defer a.connCloseWait.Done()
335327
defer statisticsListener.Close()

agent/agent_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"golang.org/x/xerrors"
2525
"tailscale.com/net/speedtest"
26+
"tailscale.com/tailcfg"
2627

2728
scp "github.com/bramvdbogaerde/go-scp"
2829
"github.com/google/uuid"
@@ -559,6 +560,7 @@ func TestAgent(t *testing.T) {
559560
agentID: uuid.New(),
560561
metadata: codersdk.WorkspaceAgentMetadata{
561562
GitAuthConfigs: 1,
563+
DERPMap: &tailcfg.DERPMap{},
562564
},
563565
statsChan: make(chan *codersdk.AgentStats),
564566
coordinator: tailnet.NewCoordinator(),

0 commit comments

Comments
 (0)