Skip to content

Commit

Permalink
server: Fix defer function closure escape
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
  • Loading branch information
serathius committed Mar 30, 2023
1 parent afc4d73 commit 6722cb7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,17 +685,17 @@ func configureClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err erro
sctx.l = transport.LimitListener(sctx.l, int(fdLimit-reservedInternalFDNum))
}

defer func(addr string) {
defer func(sctx *serveCtx) {
if err == nil || sctx.l == nil {
return
}
sctx.l.Close()
cfg.logger.Warn(
"closing peer listener",
zap.String("address", addr),
zap.String("address", sctx.addr),
zap.Error(err),
)
}(sctx.addr)
}(sctx)
for k := range cfg.UserHandlers {
sctx.userHandlers[k] = cfg.UserHandlers[k]
}
Expand Down

0 comments on commit 6722cb7

Please sign in to comment.