The done channel is a global variable. createDataServer function is covered by a mutex, but the part that closes the channel is in a different goroutine - which isn't tracked. This can lead to the following race condition: 1. createDataServer called. 2. UnregisterEndpoint called. The goroutine from createDataServer wasn't called yet. 3. createDataServer called. The goroutine from the first createDataServer is called now, and it just closed the new done channel. 4. UnregisterEndpoint called. The goroutine from the second createDataServer is called now, and it closes a closed channel - panic. The solution is to pass the done channel to the goroutine scope. Signed-off-by: Kobi Levi <kobilevi503@gmail.com>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|