TUN-2955: Fix connection and goroutine leaks when tunnel conection is terminated on error. Only unregister tunnels that had connected successfully. Close edge connection used to unregister the tunnel. Use buffered channels for error channels where receiver may quit early on context cancellation.

This commit is contained in:
Igor Postelnik
2020-05-05 17:56:39 -05:00
committed by Chung Ting Huang
parent c3fa4552aa
commit fbe2989f61
5 changed files with 35 additions and 9 deletions

View File

@@ -30,7 +30,11 @@ func (f *File) Add(filepath string) error {
// Shutdown stop the file watching run loop
func (f *File) Shutdown() {
f.shutdown <- struct{}{}
// don't block if Start quit early
select {
case f.shutdown <- struct{}{}:
default:
}
}
// Start is a runloop to watch for files changes from the file paths added from Add()