From 45df696bf3fe3eda15bbf0f2c00ddc2cfeddcdcc Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Wed, 31 Mar 2021 14:15:08 +0800 Subject: [PATCH] Fix return event publishing error Signed-off-by: Shiming Zhang --- cmd/containerd-shim/main_unix.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/containerd-shim/main_unix.go b/cmd/containerd-shim/main_unix.go index 43bf71d4d..a778f0a16 100644 --- a/cmd/containerd-shim/main_unix.go +++ b/cmd/containerd-shim/main_unix.go @@ -297,7 +297,10 @@ func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event cmd := exec.CommandContext(ctx, containerdBinaryFlag, "--address", l.address, "publish", "--topic", topic, "--namespace", ns) cmd.Stdin = bytes.NewReader(data) b := bufPool.Get().(*bytes.Buffer) - defer bufPool.Put(b) + defer func() { + b.Reset() + bufPool.Put(b) + }() cmd.Stdout = b cmd.Stderr = b c, err := reaper.Default.Start(cmd)