mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-12-22 16:07:31 +00:00
Fix deadlock when reconfiguring multicast
This commit is contained in:
parent
88925d3e06
commit
2ef823e69c
@ -76,14 +76,17 @@ func (l *link) init(c *Core) error {
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
e := <-l.reconfigure
|
e := <-l.reconfigure
|
||||||
response := make(chan error)
|
tcpresponse := make(chan error)
|
||||||
l.tcp.reconfigure <- response
|
awdlresponse := make(chan error)
|
||||||
if err := <-response; err != nil {
|
l.tcp.reconfigure <- tcpresponse
|
||||||
|
if err := <-tcpresponse; err != nil {
|
||||||
e <- err
|
e <- err
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
l.awdl.reconfigure <- response
|
l.awdl.reconfigure <- awdlresponse
|
||||||
if err := <-response; err != nil {
|
if err := <-awdlresponse; err != nil {
|
||||||
e <- err
|
e <- err
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
e <- nil
|
e <- nil
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ package yggdrasil
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
@ -57,10 +58,10 @@ func (t *tcp) getAddr() *net.TCPAddr {
|
|||||||
// to multicast.go, which obviously is not great, but right now multicast.go
|
// to multicast.go, which obviously is not great, but right now multicast.go
|
||||||
// doesn't have the ability to send more than one address in a packet either
|
// doesn't have the ability to send more than one address in a packet either
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
|
defer t.mutex.Unlock()
|
||||||
for _, listener := range t.listeners {
|
for _, listener := range t.listeners {
|
||||||
return listener.Addr().(*net.TCPAddr)
|
return listener.Addr().(*net.TCPAddr)
|
||||||
}
|
}
|
||||||
t.mutex.Unlock()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +86,7 @@ func (t *tcp) init(l *link) error {
|
|||||||
if len(added) > 0 || len(deleted) > 0 {
|
if len(added) > 0 || len(deleted) > 0 {
|
||||||
for _, add := range added {
|
for _, add := range added {
|
||||||
if add[:6] != "tcp://" {
|
if add[:6] != "tcp://" {
|
||||||
|
e <- errors.New("unknown scheme: " + add)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := t.listen(add[6:]); err != nil {
|
if err := t.listen(add[6:]); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user