Skip to content

Commit

Permalink
embed: fix blocking Close before gRPC server start
Browse files Browse the repository at this point in the history
If 'StartEtcd' returns before starting gRPC server
(e.g. mismatch snapshot, misconfiguration),
receiving from grpcServerC blocks forever. This patch
just closes the channel to not block on grpcServerC,
and proceeds to next stop operations in Close.

This was masking the issues in etcd-io#7834

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed May 1, 2017
1 parent 3f1f5e5 commit 8da518f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
return
}
if e.sctxs, err = startClientListeners(cfg); err != nil {
// errored before starting gRPC server for serveCtx.grpcServerC
for _, sctx := range e.sctxs {
close(sctx.grpcServerC)
}
return
}
for _, sctx := range e.sctxs {
Expand Down Expand Up @@ -127,6 +131,10 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
}

if e.Server, err = etcdserver.NewServer(srvcfg); err != nil {
// errored before starting gRPC server for serveCtx.grpcServerC
for _, sctx := range e.sctxs {
close(sctx.grpcServerC)
}
return
}

Expand Down

0 comments on commit 8da518f

Please sign in to comment.