Skip to content

Commit

Permalink
fix worker thread so it can complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Martinez committed May 25, 2018
1 parent 96ec428 commit 73db9b2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions engine/runner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ func (w ActionWorker) Start() {
for !done {
select {
case result := <-handler.result:
logger.Debugf("Action-Worker-%d: Received result: %#v", w.ID, result)
actionData.arc <- result
if handler.replyCnt == 1 {
logger.Debugf("Action-Worker-%d: Received result: %#v", w.ID, result)
actionData.arc <- result
}
case <-handler.done:
if !handler.replied {
if handler.replyCnt == 0 {
actionData.arc <- &ActionResult{}
}
done = true
Expand Down Expand Up @@ -152,12 +154,12 @@ func (w ActionWorker) Stop() {
type AsyncResultHandler struct {
done chan (bool)
result chan (*ActionResult)
replied bool
replyCnt int
}

// HandleResult implements action.ResultHandler.HandleResult
func (rh *AsyncResultHandler) HandleResult(results map[string]*data.Attribute, err error) {
rh.replied = true
rh.replyCnt++
rh.result <- &ActionResult{results: results, err: err}
}

Expand Down

0 comments on commit 73db9b2

Please sign in to comment.