mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: avoid closing a watch with ID 0 incorrectly
Signed-off-by: Kafuu Chino <KafuuChinoQ@gmail.com> add test 1 1 1 1 1 1
This commit is contained in:
@@ -20,12 +20,9 @@ import (
|
||||
"sync"
|
||||
|
||||
"go.etcd.io/etcd/api/v3/mvccpb"
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
)
|
||||
|
||||
// AutoWatchID is the watcher ID passed in WatchStream.Watch when no
|
||||
// user-provided ID is available. If pass, an ID will automatically be assigned.
|
||||
const AutoWatchID WatchID = 0
|
||||
|
||||
var (
|
||||
ErrWatcherNotExist = errors.New("mvcc: watcher does not exist")
|
||||
ErrEmptyWatcherRange = errors.New("mvcc: watcher range is empty")
|
||||
@@ -118,7 +115,7 @@ func (ws *watchStream) Watch(id WatchID, key, end []byte, startRev int64, fcs ..
|
||||
return -1, ErrEmptyWatcherRange
|
||||
}
|
||||
|
||||
if id == AutoWatchID {
|
||||
if id == clientv3.AutoWatchID {
|
||||
for ws.watchers[ws.nextID] != nil {
|
||||
ws.nextID++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user