X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e1dbdc4b39eb8c75c088f971cee0e7bad92b2848..e88a0a3ff00fd5448f893909d08ee11dc301776e:/sdk/go/keepclient/support.go diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go index 8be178036a..0791d3cf85 100644 --- a/sdk/go/keepclient/support.go +++ b/sdk/go/keepclient/support.go @@ -94,8 +94,8 @@ func (this *KeepClient) DiscoverKeepServers() error { return this.loadKeepServers(list) } -// DiscoverKeepServersFromJSON gets list of available keep services from given JSON -func (this *KeepClient) DiscoverKeepServersFromJSON(services string) error { +// LoadKeepServicesFromJSON gets list of available keep services from given JSON +func (this *KeepClient) LoadKeepServicesFromJSON(services string) error { var list svcList // Load keep services from given json @@ -248,7 +248,17 @@ func (this KeepClient) putReplicas( // Used to communicate status from the upload goroutines upload_status := make(chan uploadStatus) - defer close(upload_status) + defer func() { + // Wait for any abandoned uploads (e.g., we started + // two uploads and the first replied with replicas=2) + // to finish before closing the status channel. + go func() { + for active > 0 { + <-upload_status + } + close(upload_status) + }() + }() // Desired number of replicas remaining_replicas := this.Want_replicas