From 567dcaf79db4683fba80f50efba224dba7c43d8f Mon Sep 17 00:00:00 2001 From: James Shubin Date: Sat, 1 Oct 2016 08:19:46 -0400 Subject: [PATCH] resources: fix deadlock on recursion This was a sneaky deadlock which wasn't 100% reproducible. It was pretty tricky to find because the same deadlocked behaviour was seen due to the regression in the fsnotify module. The event system needs a bit of a cleaning, but this can happen later. --- resources/resources.go | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/resources/resources.go b/resources/resources.go index 7d0a2904..45107ecf 100644 --- a/resources/resources.go +++ b/resources/resources.go @@ -242,22 +242,24 @@ func (obj *BaseRes) SetState(state ResState) { func (obj *BaseRes) DoSend(processChan chan event.Event, comment string) (bool, error) { resp := event.NewResp() processChan <- event.Event{event.EventNil, resp, comment, true} // trigger process - select { - case e := <-resp: // wait for the ACK() - if e != nil { // we got a NACK - return true, e // exit with error - } - - case event := <-obj.events: - // NOTE: this code should match the similar code below! - //cuuid.SetConverged(false) // TODO ? - if exit, send := obj.ReadEvent(&event); exit { - return true, nil // exit, without error - } else if send { - return obj.DoSend(processChan, comment) // recurse - } - } - return false, nil // return, no error or exit signal + e := resp.Wait() + return false, e // XXX: at the moment, we don't use the exit bool. + // XXX: this can cause a deadlock. do we need to recursively send? fix event stuff! + //select { + //case e := <-resp: // wait for the ACK() + // if e != nil { // we got a NACK + // return true, e // exit with error + // } + //case event := <-obj.events: + // // NOTE: this code should match the similar code below! + // //cuuid.SetConverged(false) // TODO ? + // if exit, send := obj.ReadEvent(&event); exit { + // return true, nil // exit, without error + // } else if send { + // return obj.DoSend(processChan, comment) // recurse + // } + //} + //return false, nil // return, no error or exit signal } // SendEvent pushes an event into the message queue for a particular vertex