]> source.dussan.org Git - gitea.git/commit
Prevent dangling cat-file calls (goroutine alternative) (#19454)
authorzeripath <art27@cantab.net>
Fri, 22 Apr 2022 15:20:04 +0000 (16:20 +0100)
committerGitHub <noreply@github.com>
Fri, 22 Apr 2022 15:20:04 +0000 (17:20 +0200)
commit0dcc74a8a7eebe816f855ad0375714c52f8b785a
tree3cf17d682ece3424a22079f4f7aae9b150308c3f
parent0dfc2e55ea258d2b1a3cd86e2b6f27a481e495ff
Prevent dangling cat-file calls (goroutine alternative) (#19454)

If an `os/exec.Command` is passed non `*os.File` as an input/output, go
will create `os.Pipe`s and wait for their closure in `cmd.Wait()`.  If
the code following this is responsible for closing `io.Pipe`s or other
handlers then on process death from context cancellation the `Wait` can
hang.

There are two possible solutions:

1. use `os.Pipe` as the input/output as `cmd.Wait` does not wait for these.
2. create a goroutine waiting on the context cancellation that will close the inputs.

This PR provides the second option - which is a simpler change that can
be more easily backported.

Closes #19448

Signed-off-by: Andrew Thornton <art27@cantab.net>
modules/git/batch_reader.go