From efb59d97095555d114c5d0d05e2514c509f51287 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 1 Feb 2020 02:46:50 +0300 Subject: [PATCH] fix map race condition in grpc server Signed-off-by: Vasiliy Tolstov --- server/grpc/grpc.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/grpc/grpc.go b/server/grpc/grpc.go index 7a098e86..d014734a 100644 --- a/server/grpc/grpc.go +++ b/server/grpc/grpc.go @@ -562,11 +562,17 @@ func (g *grpcServer) Register() error { return err } + // make copy of metadata + md := make(meta.Metadata) + for k, v := range config.Metadata { + md[k] = v + } + // register service node := ®istry.Node{ Id: config.Name + "-" + config.Id, Address: mnet.HostPort(addr, port), - Metadata: config.Metadata, + Metadata: md, } node.Metadata["broker"] = config.Broker.String()