resources: Don't double close on Running restart
If we use the "retry" metaparam on a Watch, we want to avoid a double close due to the second Running() signal. This avoids this with a simple flag.
This commit is contained in:
@@ -197,6 +197,7 @@ type BaseRes struct {
|
|||||||
state ResState
|
state ResState
|
||||||
working bool // is the Worker() loop running ?
|
working bool // is the Worker() loop running ?
|
||||||
started chan struct{} // closed when worker is started/running
|
started chan struct{} // closed when worker is started/running
|
||||||
|
isStarted bool // did the started chan already close?
|
||||||
starter bool // does this have indegree == 0 ? XXX: usually?
|
starter bool // does this have indegree == 0 ? XXX: usually?
|
||||||
isStateOK bool // whether the state is okay based on events or not
|
isStateOK bool // whether the state is okay based on events or not
|
||||||
isGrouped bool // am i contained within a group?
|
isGrouped bool // am i contained within a group?
|
||||||
|
|||||||
@@ -108,8 +108,11 @@ func (obj *BaseRes) Running(processChan chan *event.Event) error {
|
|||||||
cuid.SetConverged(true) // a reasonable initial assumption
|
cuid.SetConverged(true) // a reasonable initial assumption
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.StateOK(false) // assume we're initially dirty
|
obj.StateOK(false) // assume we're initially dirty
|
||||||
close(obj.started) // send started signal
|
if !obj.isStarted { // this avoids a double close when/if watch retries
|
||||||
|
obj.isStarted = true
|
||||||
|
close(obj.started) // send started signal
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if obj.starter { // vertices of indegree == 0 should send initial pokes
|
if obj.starter { // vertices of indegree == 0 should send initial pokes
|
||||||
|
|||||||
Reference in New Issue
Block a user