mirror of
https://github.com/containers/podman.git
synced 2025-10-19 12:12:36 +08:00
Merge pull request #23170 from Luap99/events
podman events: fix error race
This commit is contained in:
@ -163,6 +163,7 @@ func eventsCmd(cmd *cobra.Command, _ []string) error {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
errChannel <- registry.ContainerEngine().Events(context.Background(), eventOptions)
|
errChannel <- registry.ContainerEngine().Events(context.Background(), eventOptions)
|
||||||
|
close(errChannel)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -170,14 +171,8 @@ func eventsCmd(cmd *cobra.Command, _ []string) error {
|
|||||||
case event, ok := <-eventChannel:
|
case event, ok := <-eventChannel:
|
||||||
if !ok {
|
if !ok {
|
||||||
// channel was closed we can exit
|
// channel was closed we can exit
|
||||||
select {
|
// read the error channel blocking to make sure we are not missing any errors (#23165)
|
||||||
case err := <-errChannel:
|
return <-errChannel
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case doJSON:
|
case doJSON:
|
||||||
|
Reference in New Issue
Block a user