Skip to content

Commit

Permalink
client/v3: fix issue #17611
Browse files Browse the repository at this point in the history
Signed-off-by: ganhy4@chinatelecom.cn <ganhy4@chinatelecom.cn>
  • Loading branch information
ganhy4@chinatelecom.cn committed Mar 21, 2024
1 parent 6f55dfa commit 5b22764
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/v3/watch.go
Expand Up @@ -455,12 +455,13 @@ func (w *watcher) closeStream(wgs *watchGRPCStream) {
w.mu.Unlock()
}

func (w *watchGRPCStream) addSubstream(resp *pb.WatchResponse, ws *watcherStream) {
func (w *watchGRPCStream) addSubstream(resp *pb.WatchResponse, ws *watcherStream, closing map[*watcherStream]struct{}) {
// check watch ID for backward compatibility (<= v3.3)
if resp.WatchId == InvalidWatchID || (resp.Canceled && resp.CancelReason != "") {
w.closeErr = v3rpc.Error(errors.New(resp.CancelReason))
// failed; no channel
close(ws.recvc)
closing[ws] = struct{}{}
return
}
ws.id = resp.WatchId
Expand Down Expand Up @@ -591,7 +592,7 @@ func (w *watchGRPCStream) run() {
// response to head of queue creation
if len(w.resuming) != 0 {
if ws := w.resuming[0]; ws != nil {
w.addSubstream(pbresp, ws)
w.addSubstream(pbresp, ws, closing)
w.dispatchEvent(pbresp)
w.resuming[0] = nil
}
Expand Down

0 comments on commit 5b22764

Please sign in to comment.