From 5a25388d84f49648156860d52e01220b5680896f Mon Sep 17 00:00:00 2001 From: Norwin Roosen Date: Sat, 2 Jan 2021 15:49:30 +0100 Subject: [PATCH] partially fix exit race condition in local mode --- rpc/dottir.go | 9 +++++---- rpc/ran.go | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rpc/dottir.go b/rpc/dottir.go index ed55b96..21b13b5 100644 --- a/rpc/dottir.go +++ b/rpc/dottir.go @@ -27,9 +27,8 @@ func ConnectHevring(ránAddress string, stop chan bool, wg *sync.WaitGroup) { h.wg = wg h.wg.Add(1) go func() { - select { - case <-h.quit: - } + <-h.quit + h.quit = nil if h.taskQuit != nil { close(h.taskQuit) h.taskQuit = nil @@ -93,7 +92,9 @@ func (h *Hevring) Die(x int, reply *FlutAck) error { go func() { fmt.Println("[hevring] Rán disconnected, stopping") time.Sleep(100 * time.Millisecond) - close(h.quit) + if h.quit != nil { + close(h.quit) + } }() reply.Ok = true return nil diff --git a/rpc/ran.go b/rpc/ran.go index 0f2928c..263ede7 100644 --- a/rpc/ran.go +++ b/rpc/ran.go @@ -133,6 +133,7 @@ func (r *Rán) handleExit(stopChan <-chan bool, wg *sync.WaitGroup) { ack := FlutAck{} c.Call("Hevring.Die", 0, &ack) // @speed: async } + // FIXME: why the fuck are we quitting before this loop is complete? } // SetTask assigns a pixelflut.FlutTask to Rán, distributing it to all clients