From: Vladimir Popov Date: Mon, 27 Sep 2021 04:21:20 +0000 (+0700) Subject: core: close Stream after Connection.Invoke X-Git-Tag: v0.4.0~6 X-Git-Url: https://gerrit.fd.io/r/gitweb?p=govpp.git;a=commitdiff_plain;h=385ccc0d8ba929f39881efb7784bfb0921044ae8 core: close Stream after Connection.Invoke Fixes core.Stream leaking on every core.(*Connection).Invoke() https://lists.fd.io/g/govpp-dev/topic/govpp_is_leaking_channels_on/85836420 Signed-off-by: Vladimir Popov Change-Id: I8d5bcb3c3aa40ccda3fb249ee80bb82809f284b1 --- diff --git a/core/stream.go b/core/stream.go index 363cc9f..2f639b0 100644 --- a/core/stream.go +++ b/core/stream.go @@ -70,6 +70,7 @@ func (c *Connection) Invoke(ctx context.Context, req api.Message, reply api.Mess if err != nil { return err } + defer func() { _ = stream.Close() }() if err := stream.SendMsg(req); err != nil { return err }