mirror of
https://github.com/containers/podman.git
synced 2025-05-30 07:04:03 +08:00

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>
31 lines
723 B
Go
31 lines
723 B
Go
package events
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// EventToNull is an eventer type that only performs write operations
|
|
// and only writes to /dev/null. It is meant for unittests only
|
|
type EventToNull struct{}
|
|
|
|
// Write eats the event and always returns nil
|
|
func (e EventToNull) Write(ee Event) error {
|
|
return nil
|
|
}
|
|
|
|
// Read does nothing. Do not use it.
|
|
func (e EventToNull) Read(ctx context.Context, options ReadOptions) error {
|
|
return nil
|
|
}
|
|
|
|
// NewNullEventer returns a new null eventer. You should only do this for
|
|
// the purposes on internal libpod testing.
|
|
func NewNullEventer() Eventer {
|
|
return EventToNull{}
|
|
}
|
|
|
|
// String returns a string representation of the logger
|
|
func (e EventToNull) String() string {
|
|
return "none"
|
|
}
|