mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix(mod/lock): Use dedicated channel to shutdown goroutine properly
If closeChan is available and stopWatchChan was closed by defer select selects a single channel randomly. This causes a panic sending to closed channel.
This commit is contained in:
parent
a417782151
commit
4c2942f9f9
@ -146,14 +146,17 @@ func (h *handler) ttlKeepAlive(k string, value string, ttl int, stopChan chan bo
|
||||
func (h *handler) watch(keypath string, index int, closeChan <- chan bool) error {
|
||||
// Wrap close chan so we can pass it to Client.Watch().
|
||||
stopWatchChan := make(chan bool)
|
||||
stopWrapChan := make(chan bool)
|
||||
go func() {
|
||||
select {
|
||||
case <- closeChan:
|
||||
stopWatchChan <- true
|
||||
case <- stopWrapChan:
|
||||
stopWatchChan <- true
|
||||
case <- stopWatchChan:
|
||||
}
|
||||
}()
|
||||
defer close(stopWatchChan)
|
||||
defer close(stopWrapChan)
|
||||
|
||||
for {
|
||||
// Read all nodes for the lock.
|
||||
|
Loading…
x
Reference in New Issue
Block a user