mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Close channel of started servers even if embed server fails to start.
Before this change: ``` gwmux, err = sctx.registerGateway([]grpc.DialOption{grpc.WithInsecure()}) if err != nil { return err; } ``` caused the Etcd.Serve() method finish without sctx.serversC channel being closed. The code closing Etcd got stuck waiting for all the servers to be running. Signed-off-by: Piotr Tabor <ptab@google.com>
This commit is contained in:
parent
fcc8fce4d2
commit
1c401581e3
@ -120,6 +120,9 @@ func (sctx *serveCtx) serve(
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// Make sure serversC is closed even if we prematurely exit the function.
|
||||||
|
defer close(sctx.serversC)
|
||||||
|
|
||||||
if sctx.insecure {
|
if sctx.insecure {
|
||||||
gs = v3rpc.Server(s, nil, nil, gopts...)
|
gs = v3rpc.Server(s, nil, nil, gopts...)
|
||||||
v3electionpb.RegisterElectionServer(gs, servElection)
|
v3electionpb.RegisterElectionServer(gs, servElection)
|
||||||
@ -203,7 +206,6 @@ func (sctx *serveCtx) serve(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
close(sctx.serversC)
|
|
||||||
return m.Serve()
|
return m.Serve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user