From 9763820c75c17df2578bed1458852cbdc69209bc Mon Sep 17 00:00:00 2001
From: Vasiliy Tolstov <v.tolstov@unistack.org>
Date: Mon, 25 Nov 2019 22:02:24 +0300
Subject: [PATCH] grpc client goroutine leak fix

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
---
 client/grpc/stream.go | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/client/grpc/stream.go b/client/grpc/stream.go
index af919e46..c6b38c15 100644
--- a/client/grpc/stream.go
+++ b/client/grpc/stream.go
@@ -43,14 +43,12 @@ func (g *grpcStream) Send(msg interface{}) error {
 func (g *grpcStream) Recv(msg interface{}) (err error) {
 	defer g.setError(err)
 	if err = g.stream.RecvMsg(msg); err != nil {
-		if err == io.EOF {
-			// #202 - inconsistent gRPC stream behavior
-			// the only way to tell if the stream is done is when we get a EOF on the Recv
-			// here we should close the underlying gRPC ClientConn
-			closeErr := g.conn.Close()
-			if closeErr != nil {
-				err = closeErr
-			}
+		// #202 - inconsistent gRPC stream behavior
+		// the only way to tell if the stream is done is when we get a EOF on the Recv
+		// here we should close the underlying gRPC ClientConn
+		closeErr := g.conn.Close()
+		if err == io.EOF && closeErr != nil {
+			err = closeErr
 		}
 	}
 	return