diff --git a/examples/pubsub/chat/go.sum b/examples/pubsub/chat/go.sum index cea24724..360c46ad 100644 --- a/examples/pubsub/chat/go.sum +++ b/examples/pubsub/chat/go.sum @@ -350,7 +350,6 @@ github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABo github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8/go.mod h1:Ly/wlsjFq/qrU3Rar62tu1gASgGw6chQbSh/XgIIXCY= github.com/jbenet/goprocess v0.1.3/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= -github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= diff --git a/go.mod b/go.mod index 9b662e95..0720c2fe 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,6 @@ require ( github.com/ipfs/go-datastore v0.5.0 github.com/ipfs/go-ipfs-util v0.0.2 github.com/ipfs/go-log/v2 v2.4.0 - github.com/jbenet/goprocess v0.1.4 github.com/klauspost/cpuid/v2 v2.0.9 // indirect github.com/koron/go-ssdp v0.0.2 // indirect github.com/libp2p/go-addr-util v0.1.0 diff --git a/p2p/net/mock/mock_conn.go b/p2p/net/mock/mock_conn.go index 2d549c3c..d16908c7 100644 --- a/p2p/net/mock/mock_conn.go +++ b/p2p/net/mock/mock_conn.go @@ -7,7 +7,6 @@ import ( "sync" "sync/atomic" - process "github.com/jbenet/goprocess" ic "github.com/libp2p/go-libp2p-core/crypto" "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" @@ -40,13 +39,13 @@ type conn struct { streams list.List stat network.ConnStats - pairProc, connProc process.Process + closeOnce sync.Once sync.RWMutex } -func newConn(p process.Process, ln, rn *peernet, l *link, dir network.Direction) *conn { - c := &conn{net: ln, link: l, pairProc: p} +func newConn(ln, rn *peernet, l *link, dir network.Direction) *conn { + c := &conn{net: ln, link: l} c.local = ln.peer c.remote = rn.peer c.stat.Direction = dir @@ -65,7 +64,6 @@ func newConn(p process.Process, ln, rn *peernet, l *link, dir network.Direction) c.localPrivKey = ln.ps.PrivKey(ln.peer) c.remotePubKey = rn.ps.PubKey(rn.peer) - c.connProc = process.WithParent(c.pairProc) return c } @@ -74,11 +72,11 @@ func (c *conn) ID() string { } func (c *conn) Close() error { - return c.pairProc.Close() -} - -func (c *conn) setup() { - c.connProc.SetTeardown(c.teardown) + c.closeOnce.Do(func() { + go c.rconn.Close() + c.teardown() + }) + return nil } func (c *conn) teardown() error { diff --git a/p2p/net/mock/mock_link.go b/p2p/net/mock/mock_link.go index 2c7743be..fe65398e 100644 --- a/p2p/net/mock/mock_link.go +++ b/p2p/net/mock/mock_link.go @@ -6,8 +6,6 @@ import ( "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" - - process "github.com/jbenet/goprocess" ) // link implements mocknet.Link @@ -33,13 +31,12 @@ func (l *link) newConnPair(dialer *peernet) (*conn, *conn) { l.RLock() defer l.RUnlock() - parent := process.WithTeardown(func() error { return nil }) target := l.nets[0] if target == dialer { target = l.nets[1] } - dc := newConn(parent, dialer, target, l, network.DirOutbound) - tc := newConn(parent, target, dialer, l, network.DirInbound) + dc := newConn(dialer, target, l, network.DirOutbound) + tc := newConn(target, dialer, l, network.DirInbound) dc.rconn = tc tc.rconn = dc return dc, tc diff --git a/p2p/net/mock/mock_peernet.go b/p2p/net/mock/mock_peernet.go index 7d0d4f04..a01f074d 100644 --- a/p2p/net/mock/mock_peernet.go +++ b/p2p/net/mock/mock_peernet.go @@ -188,9 +188,6 @@ func (pn *peernet) remoteOpenedConn(c *conn) { // to given remote peer over given link func (pn *peernet) addConn(c *conn) { defer c.notifLk.Unlock() - // Call this after unlocking as it might cause us to immediately close - // the connection and remove it from the swarm. - c.setup() pn.notifyAll(func(n network.Notifiee) { n.Connected(pn, c)