X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3ae9a789410e93eeb31ca5670c17a6d03d77f608..3c4bcfbe8611878bff64778180f84ad93829e6b2:/sdk/go/dispatch/dispatch.go diff --git a/sdk/go/dispatch/dispatch.go b/sdk/go/dispatch/dispatch.go index 785b6ec665..9fe2e396fc 100644 --- a/sdk/go/dispatch/dispatch.go +++ b/sdk/go/dispatch/dispatch.go @@ -103,14 +103,16 @@ func (dispatcher *Dispatcher) notMine(uuid string) { } // Check if there is a channel for updates associated with this container. If -// so send the container record on the channel and return true, if not return -// false. -func (dispatcher *Dispatcher) updateMine(c Container) bool { +// so (and update is true) send the container record on the channel and return +// true, if not return false. +func (dispatcher *Dispatcher) checkMine(c Container, update bool) bool { dispatcher.mineMutex.Lock() defer dispatcher.mineMutex.Unlock() ch, ok := dispatcher.mineMap[c.UUID] if ok { - ch <- c + if update { + ch <- c + } return true } return false @@ -174,9 +176,13 @@ func (dispatcher *Dispatcher) pollContainers() { } func (dispatcher *Dispatcher) handleUpdate(container Container) { + if container.State == Queued && dispatcher.checkMine(container, false) { + dispatcher.notMine(container.UUID) + } + if container.LockedByUUID != dispatcher.Auth.UUID && container.State != Queued { // If container is Complete, Cancelled, or Queued, LockedByUUID - // will be nil. If the container was formally Locked, moved + // will be nil. If the container was formerly Locked, moved // back to Queued and then locked by another dispatcher, // LockedByUUID will be different. In either case, we want // to stop monitoring it. @@ -185,7 +191,7 @@ func (dispatcher *Dispatcher) handleUpdate(container Container) { return } - if dispatcher.updateMine(container) { + if dispatcher.checkMine(container, true) { // Already monitored, sent status update return }