partially fix exit race condition in local mode

This commit is contained in:
Norwin Roosen 2021-01-02 15:49:30 +01:00
parent 4860070a6b
commit 5a25388d84
No known key found for this signature in database
GPG Key ID: 24BC059DE24C43A3
2 changed files with 6 additions and 4 deletions

View File

@ -27,9 +27,8 @@ func ConnectHevring(ránAddress string, stop chan bool, wg *sync.WaitGroup) {
h.wg = wg h.wg = wg
h.wg.Add(1) h.wg.Add(1)
go func() { go func() {
select { <-h.quit
case <-h.quit: h.quit = nil
}
if h.taskQuit != nil { if h.taskQuit != nil {
close(h.taskQuit) close(h.taskQuit)
h.taskQuit = nil h.taskQuit = nil
@ -93,7 +92,9 @@ func (h *Hevring) Die(x int, reply *FlutAck) error {
go func() { go func() {
fmt.Println("[hevring] Rán disconnected, stopping") fmt.Println("[hevring] Rán disconnected, stopping")
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
close(h.quit) if h.quit != nil {
close(h.quit)
}
}() }()
reply.Ok = true reply.Ok = true
return nil return nil

View File

@ -133,6 +133,7 @@ func (r *Rán) handleExit(stopChan <-chan bool, wg *sync.WaitGroup) {
ack := FlutAck{} ack := FlutAck{}
c.Call("Hevring.Die", 0, &ack) // @speed: async 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 // SetTask assigns a pixelflut.FlutTask to Rán, distributing it to all clients