File tree 1 file changed +2
-2
lines changed
1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,7 @@ func (as *autoNATService) Enable() {
242
242
ctx , cancel := context .WithCancel (context .Background ())
243
243
as .instance = cancel
244
244
as .backgroundRunning = make (chan struct {})
245
+ as .config .host .SetStreamHandler (AutoNATProto , as .handleStream )
245
246
246
247
go as .background (ctx )
247
248
}
@@ -251,6 +252,7 @@ func (as *autoNATService) Disable() {
251
252
as .instanceLock .Lock ()
252
253
defer as .instanceLock .Unlock ()
253
254
if as .instance != nil {
255
+ as .config .host .RemoveStreamHandler (AutoNATProto )
254
256
as .instance ()
255
257
as .instance = nil
256
258
<- as .backgroundRunning
@@ -259,7 +261,6 @@ func (as *autoNATService) Disable() {
259
261
260
262
func (as * autoNATService ) background (ctx context.Context ) {
261
263
defer close (as .backgroundRunning )
262
- as .config .host .SetStreamHandler (AutoNATProto , as .handleStream )
263
264
264
265
timer := time .NewTimer (as .config .throttleResetPeriod )
265
266
defer timer .Stop ()
@@ -274,7 +275,6 @@ func (as *autoNATService) background(ctx context.Context) {
274
275
jitter := rand .Float32 () * float32 (as .config .throttleResetJitter )
275
276
timer .Reset (as .config .throttleResetPeriod + time .Duration (int64 (jitter )))
276
277
case <- ctx .Done ():
277
- as .config .host .RemoveStreamHandler (AutoNATProto )
278
278
return
279
279
}
280
280
}
You can’t perform that action at this time.
0 commit comments