summaryrefslogtreecommitdiff
path: root/pkg/domain/infra
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-07-01 16:21:57 -0400
committerMatthew Heon <matthew.heon@pm.me>2020-07-02 09:57:39 -0400
commit9e4cf6ca513fa0646f33ade14955e1fc4335e176 (patch)
tree9c820378fb4e2d0873ca24da5766691ffc4b6ccd /pkg/domain/infra
parent1a1e3f4b24e6f856a5c2e16da0cc34a8191c9403 (diff)
downloadpodman-9e4cf6ca513fa0646f33ade14955e1fc4335e176.tar.gz
podman-9e4cf6ca513fa0646f33ade14955e1fc4335e176.tar.bz2
podman-9e4cf6ca513fa0646f33ade14955e1fc4335e176.zip
Fix `system service` panic from early hangup in events
We weren't actually halting the goroutine that sent events, so it would continue sending even when the channel closed (the most notable cause being early hangup - e.g. Control-c on a curl session). Use a context to cancel the events goroutine and stop sending events. Fixes #6805 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r--pkg/domain/infra/abi/containers.go4
-rw-r--r--pkg/domain/infra/abi/events.go2
2 files changed, 3 insertions, 3 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index 22de28a1c..f31ea3945 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -741,7 +741,7 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
if ecode, err := ctr.Wait(); err != nil {
if errors.Cause(err) == define.ErrNoSuchCtr {
// Check events
- event, err := ic.Libpod.GetLastContainerEvent(ctr.ID(), events.Exited)
+ event, err := ic.Libpod.GetLastContainerEvent(ctx, ctr.ID(), events.Exited)
if err != nil {
logrus.Errorf("Cannot get exit code: %v", err)
exitCode = define.ExecErrorCodeNotFound
@@ -871,7 +871,7 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
if ecode, err := ctr.Wait(); err != nil {
if errors.Cause(err) == define.ErrNoSuchCtr {
// Check events
- event, err := ic.Libpod.GetLastContainerEvent(ctr.ID(), events.Exited)
+ event, err := ic.Libpod.GetLastContainerEvent(ctx, ctr.ID(), events.Exited)
if err != nil {
logrus.Errorf("Cannot get exit code: %v", err)
report.ExitCode = define.ExecErrorCodeNotFound
diff --git a/pkg/domain/infra/abi/events.go b/pkg/domain/infra/abi/events.go
index 7ec9db369..c999faeee 100644
--- a/pkg/domain/infra/abi/events.go
+++ b/pkg/domain/infra/abi/events.go
@@ -9,5 +9,5 @@ import (
func (ic *ContainerEngine) Events(ctx context.Context, opts entities.EventsOptions) error {
readOpts := events.ReadOptions{FromStart: opts.FromStart, Stream: opts.Stream, Filters: opts.Filter, EventChannel: opts.EventChan, Since: opts.Since, Until: opts.Until}
- return ic.Libpod.Events(readOpts)
+ return ic.Libpod.Events(ctx, readOpts)
}