Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
FIX #2154 query virtualbox serially
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Nov 4, 2015
1 parent 34ee11e commit 88399f4
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions commands/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,32 @@ func getHostListItems(hostList []*host.Host) []HostListItem {
hostListItemsChan := make(chan HostListItem)

for _, h := range hostList {
go getHostState(h, hostListItemsChan)
if h.DriverName != "virtualbox" {
go getHostState(h, hostListItemsChan)
}
}

for range hostList {
hostListItems = append(hostListItems, <-hostListItemsChan)
// Virtualbox is temperamental about doing things concurrently,
// so we schedule the actions in a "queue" to be executed serially
// after the concurrent actions are scheduled.
for _, h := range hostList {
if h.DriverName == "virtualbox" {
serialChan := make(chan HostListItem)

go getHostState(h, serialChan)

hostListItems = append(hostListItems, <-serialChan)
close(serialChan)
}
}

for _, h := range hostList {
if h.DriverName != "virtualbox" {
hostListItems = append(hostListItems, <-hostListItemsChan)
}
}
close(hostListItemsChan)

return hostListItems
}

Expand Down

0 comments on commit 88399f4

Please sign in to comment.