Skip to content

Commit

Permalink
stop waiting for the ready notification if the server has stopped
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Oct 13, 2023
1 parent d0d0c33 commit 369eef7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/embed/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"go.etcd.io/etcd/server/v3/etcdserver/api/v3lock/v3lockpb"
v3lockgw "go.etcd.io/etcd/server/v3/etcdserver/api/v3lock/v3lockpb/gw"
"go.etcd.io/etcd/server/v3/etcdserver/api/v3rpc"
"go.etcd.io/etcd/server/v3/etcdserver/errors"
)

type serveCtx struct {
Expand Down Expand Up @@ -99,7 +100,12 @@ func (sctx *serveCtx) serve(
splitHttp bool,
gopts ...grpc.ServerOption) (err error) {
logger := defaultLog.New(io.Discard, "etcdhttp", 0)
<-s.ReadyNotify()

select {
case <-s.ReadyNotify(): // wait for e.Server to join the cluster
case <-s.StopNotify(): // publish aborted from 'ErrStopped'
return errors.ErrStopped
}

sctx.lg.Info("ready to serve client requests")

Expand Down

0 comments on commit 369eef7

Please sign in to comment.