mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-23 00:51:35 +00:00
Remove unnecessary selects
This commit is contained in:
parent
39567bed83
commit
2cd373fc1e
@ -57,8 +57,7 @@ func (a *admin) init(c *Core) {
|
|||||||
a.reconfigure = make(chan chan error, 1)
|
a.reconfigure = make(chan chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
e := <-a.reconfigure
|
||||||
case e := <-a.reconfigure:
|
|
||||||
a.core.configMutex.RLock()
|
a.core.configMutex.RLock()
|
||||||
if a.core.config.AdminListen != a.core.configOld.AdminListen {
|
if a.core.config.AdminListen != a.core.configOld.AdminListen {
|
||||||
a.listenaddr = a.core.config.AdminListen
|
a.listenaddr = a.core.config.AdminListen
|
||||||
@ -68,7 +67,6 @@ func (a *admin) init(c *Core) {
|
|||||||
a.core.configMutex.RUnlock()
|
a.core.configMutex.RUnlock()
|
||||||
e <- nil
|
e <- nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
a.core.configMutex.RLock()
|
a.core.configMutex.RLock()
|
||||||
a.listenaddr = a.core.config.AdminListen
|
a.listenaddr = a.core.config.AdminListen
|
||||||
|
@ -82,11 +82,9 @@ func (t *dht) init(c *Core) {
|
|||||||
t.reconfigure = make(chan chan error, 1)
|
t.reconfigure = make(chan chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
e := <-t.reconfigure
|
||||||
case e := <-t.reconfigure:
|
|
||||||
e <- nil
|
e <- nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
t.nodeID = *t.core.GetNodeID()
|
t.nodeID = *t.core.GetNodeID()
|
||||||
t.peers = make(chan *dhtInfo, 1024)
|
t.peers = make(chan *dhtInfo, 1024)
|
||||||
|
@ -25,14 +25,12 @@ func (m *multicast) init(core *Core) {
|
|||||||
m.reconfigure = make(chan chan error, 1)
|
m.reconfigure = make(chan chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
e := <-m.reconfigure
|
||||||
case e := <-m.reconfigure:
|
|
||||||
m.myAddrMutex.Lock()
|
m.myAddrMutex.Lock()
|
||||||
m.myAddr = m.core.tcp.getAddr()
|
m.myAddr = m.core.tcp.getAddr()
|
||||||
m.myAddrMutex.Unlock()
|
m.myAddrMutex.Unlock()
|
||||||
e <- nil
|
e <- nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
m.groupAddr = "[ff02::114]:9001"
|
m.groupAddr = "[ff02::114]:9001"
|
||||||
// Check if we've been given any expressions
|
// Check if we've been given any expressions
|
||||||
|
@ -35,11 +35,9 @@ func (ps *peers) init(c *Core) {
|
|||||||
ps.reconfigure = make(chan chan error, 1)
|
ps.reconfigure = make(chan chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
e := <-ps.reconfigure
|
||||||
case e := <-ps.reconfigure:
|
|
||||||
e <- nil
|
e <- nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
ps.allowedEncryptionPublicKeys = make(map[crypto.BoxPubKey]struct{})
|
ps.allowedEncryptionPublicKeys = make(map[crypto.BoxPubKey]struct{})
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,9 @@ func (s *searches) init(core *Core) {
|
|||||||
s.reconfigure = make(chan chan error, 1)
|
s.reconfigure = make(chan chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
e := <-s.reconfigure
|
||||||
case e := <-s.reconfigure:
|
|
||||||
e <- nil
|
e <- nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
s.searches = make(map[crypto.NodeID]*searchInfo)
|
s.searches = make(map[crypto.NodeID]*searchInfo)
|
||||||
}
|
}
|
||||||
|
@ -131,8 +131,7 @@ func (ss *sessions) init(core *Core) {
|
|||||||
ss.reconfigure = make(chan chan error, 1)
|
ss.reconfigure = make(chan chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
e := <-ss.reconfigure
|
||||||
case e := <-ss.reconfigure:
|
|
||||||
responses := make(map[crypto.Handle]chan error)
|
responses := make(map[crypto.Handle]chan error)
|
||||||
for index, session := range ss.sinfos {
|
for index, session := range ss.sinfos {
|
||||||
responses[index] = make(chan error)
|
responses[index] = make(chan error)
|
||||||
@ -146,7 +145,6 @@ func (ss *sessions) init(core *Core) {
|
|||||||
}
|
}
|
||||||
e <- nil
|
e <- nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
ss.permShared = make(map[crypto.BoxPubKey]*crypto.BoxSharedKey)
|
ss.permShared = make(map[crypto.BoxPubKey]*crypto.BoxSharedKey)
|
||||||
ss.sinfos = make(map[crypto.Handle]*sessionInfo)
|
ss.sinfos = make(map[crypto.Handle]*sessionInfo)
|
||||||
|
@ -90,8 +90,7 @@ func (iface *tcpInterface) init(core *Core) (err error) {
|
|||||||
iface.reconfigure = make(chan chan error, 1)
|
iface.reconfigure = make(chan chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
e := <-iface.reconfigure
|
||||||
case e := <-iface.reconfigure:
|
|
||||||
iface.core.configMutex.RLock()
|
iface.core.configMutex.RLock()
|
||||||
updated := iface.core.config.Listen != iface.core.configOld.Listen
|
updated := iface.core.config.Listen != iface.core.configOld.Listen
|
||||||
iface.core.configMutex.RUnlock()
|
iface.core.configMutex.RUnlock()
|
||||||
@ -103,7 +102,6 @@ func (iface *tcpInterface) init(core *Core) (err error) {
|
|||||||
e <- nil
|
e <- nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return iface.listen()
|
return iface.listen()
|
||||||
|
@ -46,8 +46,7 @@ func (tun *tunAdapter) init(core *Core, send chan<- []byte, recv <-chan []byte)
|
|||||||
tun.icmpv6.init(tun)
|
tun.icmpv6.init(tun)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
e := <-tun.reconfigure
|
||||||
case e := <-tun.reconfigure:
|
|
||||||
tun.core.configMutex.RLock()
|
tun.core.configMutex.RLock()
|
||||||
updated := tun.core.config.IfName != tun.core.configOld.IfName ||
|
updated := tun.core.config.IfName != tun.core.configOld.IfName ||
|
||||||
tun.core.config.IfTAPMode != tun.core.configOld.IfTAPMode ||
|
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
|
e <- nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user