File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,13 @@ func (a *agent) run(ctx context.Context) error {
221
221
}
222
222
223
223
func (a * agent ) createTailnet (ctx context.Context , derpMap * tailcfg.DERPMap ) (* tailnet.Conn , error ) {
224
+ a .closeMutex .Lock ()
225
+ if a .isClosed () {
226
+ a .closeMutex .Unlock ()
227
+ return nil , xerrors .New ("closed" )
228
+ }
229
+ a .connCloseWait .Add (1 )
230
+ a .closeMutex .Unlock ()
224
231
network , err := tailnet .NewConn (& tailnet.Options {
225
232
Addresses : []netip.Prefix {netip .PrefixFrom (codersdk .TailnetIP , 128 )},
226
233
DERPMap : derpMap ,
@@ -242,9 +249,6 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (*t
242
249
if err != nil {
243
250
return nil , xerrors .Errorf ("listen on the ssh port: %w" , err )
244
251
}
245
- a .closeMutex .Lock ()
246
- a .connCloseWait .Add (1 )
247
- a .closeMutex .Unlock ()
248
252
go func () {
249
253
defer a .connCloseWait .Done ()
250
254
for {
You can’t perform that action at this time.
0 commit comments