Handle errors from reconfigure tasks

This commit is contained in:
Neil Alexander 2018-12-30 12:04:42 +00:00
parent 2925920c70
commit 7fae1c993a
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
9 changed files with 64 additions and 72 deletions

View file

@ -38,7 +38,7 @@ import (
// The router's mainLoop goroutine is responsible for managing all information related to the dht, searches, and crypto sessions.
type router struct {
core *Core
reconfigure chan bool
reconfigure chan chan error
addr address.Address
subnet address.Subnet
in <-chan []byte // packets we received from the network, link to peer's "out"
@ -62,7 +62,7 @@ type router_recvPacket struct {
// Initializes the router struct, which includes setting up channels to/from the tun/tap.
func (r *router) init(core *Core) {
r.core = core
r.reconfigure = make(chan bool, 1)
r.reconfigure = make(chan chan error, 1)
r.addr = *address.AddrForNodeID(&r.core.dht.nodeID)
r.subnet = *address.SubnetForNodeID(&r.core.dht.nodeID)
in := make(chan []byte, 32) // TODO something better than this...
@ -126,11 +126,8 @@ func (r *router) mainLoop() {
}
case f := <-r.admin:
f()
case _ = <-r.reconfigure:
r.core.configMutex.RLock()
r.core.log.Println("Notified: router")
r.core.configMutex.RUnlock()
continue
case e := <-r.reconfigure:
e <- nil
}
}
}