runc icon indicating copy to clipboard operation
runc copied to clipboard

logs.go: fixed logger creation

Open AntonMoryakov opened this issue 1 year ago • 2 comments

Previously, the done channel was not closed properly in case of an error returned by logPipe.Close(), potentially leading to a goroutine leak. This commit ensures that the done channel is closed even if there's an error during the closing of logPipe.

AntonMoryakov avatar Apr 25 '24 10:04 AntonMoryakov

the done channel was not closed properly in case of an error returned by logPipe.Close()

I think we have catched the error returned by logPipe.Close(), so I think the done channel will be closed in any case. https://github.com/opencontainers/runc/blob/71524dcff4f824772f6b64df6b29a7903ac0781d/libcontainer/logs/logs.go#L30-L32

Yes, but I think it will be better to move it to defer func. Thanks.

lifubang avatar Apr 26 '24 01:04 lifubang

the done channel was not closed properly in case of an error returned by logPipe.Close()

I think we have catched the error returned by logPipe.Close(), so I think the done channel will be closed in any case.

https://github.com/opencontainers/runc/blob/71524dcff4f824772f6b64df6b29a7903ac0781d/libcontainer/logs/logs.go#L30-L32

Hmm you are right (not sure how I overlooked it).

So, while defer is indeed better, there's nothing to fix here. For this reason, I'd rather not merge this.

kolyshkin avatar Apr 26 '24 01:04 kolyshkin

@AntonMoryakov can you comment on https://github.com/opencontainers/runc/pull/4254#issuecomment-2078454118?

kolyshkin avatar May 09 '24 20:05 kolyshkin

Closing for now; will reopen depending on the PR author response.

kolyshkin avatar May 09 '24 20:05 kolyshkin