diff options
author | Paul Holzinger <pholzing@redhat.com> | 2021-10-05 11:13:49 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2021-10-06 17:51:07 +0200 |
commit | fbce7584d786ed99354a4b33a9c127abd673c3bb (patch) | |
tree | 2726f6e2df81a368323398330a786b3ae25afa64 /libpod/oci_conmon_linux.go | |
parent | 8bcc086b1b9d8aa0ef3bb08d37542adf9de26ac5 (diff) | |
download | podman-fbce7584d786ed99354a4b33a9c127abd673c3bb.tar.gz podman-fbce7584d786ed99354a4b33a9c127abd673c3bb.tar.bz2 podman-fbce7584d786ed99354a4b33a9c127abd673c3bb.zip |
libpod: fix race when closing STDIN
There is a race where `conn.Close()` was called before `conn.CloseWrite()`.
In this case `CloseWrite` will fail and an useless error is printed. To
fix this we move the the `CloseWrite()` call to the same goroutine to
remove the race. This ensures that `CloseWrite()` is called before
`Close()` and never afterwards.
Also fixed podman-remote run where the STDIN was never was closed.
This is causing flakes in CI testing.
[NO TESTS NEEDED]
Fixes #11856
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'libpod/oci_conmon_linux.go')
-rw-r--r-- | libpod/oci_conmon_linux.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index 71a7b29fa..29ec4a92a 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -701,6 +701,10 @@ func (r *ConmonOCIRuntime) HTTPAttach(ctr *Container, req *http.Request, w http. if err != nil { return err } + // copy stdin is done, close it + if connErr := conn.CloseWrite(); connErr != nil { + logrus.Errorf("Unable to close conn: %v", connErr) + } case <-cancel: return nil } |