From 549087cd69806672300ac201c40ec27b9d7e27a2 Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Thu, 30 Mar 2023 13:37:19 +0200 Subject: [PATCH] server: Fix defer function closure escape Signed-off-by: Marek Siarkowicz --- server/embed/etcd.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/embed/etcd.go b/server/embed/etcd.go index b1539361e9a..48f5cdb6b38 100644 --- a/server/embed/etcd.go +++ b/server/embed/etcd.go @@ -692,17 +692,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] }