From 9216a47724b8bf1b6e362f36a57723355db19a02 Mon Sep 17 00:00:00 2001 From: Jake Sanders Date: Tue, 19 May 2020 14:44:46 +0100 Subject: [PATCH] fix client race (#1647) --- client/rpc_client.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/client/rpc_client.go b/client/rpc_client.go index d66a918a..20d07546 100644 --- a/client/rpc_client.go +++ b/client/rpc_client.go @@ -114,8 +114,7 @@ func (r *rpcClient) call(ctx context.Context, node *registry.Node, req Request, return errors.InternalServerError("go.micro.client", "connection error: %v", err) } - seq := atomic.LoadUint64(&r.seq) - atomic.AddUint64(&r.seq, 1) + seq := atomic.AddUint64(&r.seq, 1) - 1 codec := newRpcCodec(msg, c, cf, "") rsp := &rpcResponse{ @@ -232,8 +231,7 @@ func (r *rpcClient) stream(ctx context.Context, node *registry.Node, req Request } // increment the sequence number - seq := atomic.LoadUint64(&r.seq) - atomic.AddUint64(&r.seq, 1) + seq := atomic.AddUint64(&r.seq, 1) - 1 id := fmt.Sprintf("%v", seq) // create codec with stream id