Remove unnecessary selects

This commit is contained in:
Neil Alexander 2019-01-15 08:51:19 +00:00
parent 39567bed83
commit 2cd373fc1e
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
8 changed files with 52 additions and 68 deletions

View File

@ -57,8 +57,7 @@ func (a *admin) init(c *Core) {
a.reconfigure = make(chan chan error, 1)
go func() {
for {
select {
case e := <-a.reconfigure:
e := <-a.reconfigure
a.core.configMutex.RLock()
if a.core.config.AdminListen != a.core.configOld.AdminListen {
a.listenaddr = a.core.config.AdminListen
@ -68,7 +67,6 @@ func (a *admin) init(c *Core) {
a.core.configMutex.RUnlock()
e <- nil
}
}
}()
a.core.configMutex.RLock()
a.listenaddr = a.core.config.AdminListen

View File

@ -82,11 +82,9 @@ func (t *dht) init(c *Core) {
t.reconfigure = make(chan chan error, 1)
go func() {
for {
select {
case e := <-t.reconfigure:
e := <-t.reconfigure
e <- nil
}
}
}()
t.nodeID = *t.core.GetNodeID()
t.peers = make(chan *dhtInfo, 1024)

View File

@ -25,14 +25,12 @@ func (m *multicast) init(core *Core) {
m.reconfigure = make(chan chan error, 1)
go func() {
for {
select {
case e := <-m.reconfigure:
e := <-m.reconfigure
m.myAddrMutex.Lock()
m.myAddr = m.core.tcp.getAddr()
m.myAddrMutex.Unlock()
e <- nil
}
}
}()
m.groupAddr = "[ff02::114]:9001"
// Check if we've been given any expressions

View File

@ -35,11 +35,9 @@ func (ps *peers) init(c *Core) {
ps.reconfigure = make(chan chan error, 1)
go func() {
for {
select {
case e := <-ps.reconfigure:
e := <-ps.reconfigure
e <- nil
}
}
}()
ps.allowedEncryptionPublicKeys = make(map[crypto.BoxPubKey]struct{})
}

View File

@ -53,11 +53,9 @@ func (s *searches) init(core *Core) {
s.reconfigure = make(chan chan error, 1)
go func() {
for {
select {
case e := <-s.reconfigure:
e := <-s.reconfigure
e <- nil
}
}
}()
s.searches = make(map[crypto.NodeID]*searchInfo)
}

View File

@ -131,8 +131,7 @@ func (ss *sessions) init(core *Core) {
ss.reconfigure = make(chan chan error, 1)
go func() {
for {
select {
case e := <-ss.reconfigure:
e := <-ss.reconfigure
responses := make(map[crypto.Handle]chan error)
for index, session := range ss.sinfos {
responses[index] = make(chan error)
@ -146,7 +145,6 @@ func (ss *sessions) init(core *Core) {
}
e <- nil
}
}
}()
ss.permShared = make(map[crypto.BoxPubKey]*crypto.BoxSharedKey)
ss.sinfos = make(map[crypto.Handle]*sessionInfo)

View File

@ -90,8 +90,7 @@ func (iface *tcpInterface) init(core *Core) (err error) {
iface.reconfigure = make(chan chan error, 1)
go func() {
for {
select {
case e := <-iface.reconfigure:
e := <-iface.reconfigure
iface.core.configMutex.RLock()
updated := iface.core.config.Listen != iface.core.configOld.Listen
iface.core.configMutex.RUnlock()
@ -103,7 +102,6 @@ func (iface *tcpInterface) init(core *Core) (err error) {
e <- nil
}
}
}
}()
return iface.listen()

View File

@ -46,8 +46,7 @@ func (tun *tunAdapter) init(core *Core, send chan<- []byte, recv <-chan []byte)
tun.icmpv6.init(tun)
go func() {
for {
select {
case e := <-tun.reconfigure:
e := <-tun.reconfigure
tun.core.configMutex.RLock()
updated := tun.core.config.IfName != tun.core.configOld.IfName ||
tun.core.config.IfTAPMode != tun.core.configOld.IfTAPMode ||
@ -60,7 +59,6 @@ func (tun *tunAdapter) init(core *Core, send chan<- []byte, recv <-chan []byte)
e <- nil
}
}
}
}()
}