Commit 1b20b7bb authored by Jakub Sztandera's avatar Jakub Sztandera

invalidate cache for InterfaceListenAddresses on Listen

License: MIT
Signed-off-by: default avatarJakub Sztandera <kubuxu@protonmail.ch>
parent a37c480a
...@@ -2,6 +2,7 @@ package swarm ...@@ -2,6 +2,7 @@ package swarm
import ( import (
"fmt" "fmt"
"time"
"github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/network"
...@@ -55,6 +56,7 @@ func (s *Swarm) AddListenAddr(a ma.Multiaddr) error { ...@@ -55,6 +56,7 @@ func (s *Swarm) AddListenAddr(a ma.Multiaddr) error {
} }
s.refs.Add(1) s.refs.Add(1)
s.listeners.m[list] = struct{}{} s.listeners.m[list] = struct{}{}
s.listeners.cacheEOL = time.Time{}
s.listeners.Unlock() s.listeners.Unlock()
maddr := list.Multiaddr() maddr := list.Multiaddr()
...@@ -69,6 +71,7 @@ func (s *Swarm) AddListenAddr(a ma.Multiaddr) error { ...@@ -69,6 +71,7 @@ func (s *Swarm) AddListenAddr(a ma.Multiaddr) error {
list.Close() list.Close()
s.listeners.Lock() s.listeners.Lock()
delete(s.listeners.m, list) delete(s.listeners.m, list)
s.listeners.cacheEOL = time.Time{}
s.listeners.Unlock() s.listeners.Unlock()
s.refs.Done() s.refs.Done()
}() }()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment