From 5ee3bddaadfdf823f330cba49feb896b7cfbe81d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 27 Jul 2017 18:43:54 -0700 Subject: [PATCH 1/3] notify: handle new connections asynchronously Trying to create a stream from with a connection notifier is *not* allowed (and will deadlock). Also, use the pubsub context when trying to open the stream. --- notify.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/notify.go b/notify.go index 5d94878..fdcaf39 100644 --- a/notify.go +++ b/notify.go @@ -1,8 +1,6 @@ package floodsub import ( - "context" - inet "github.com/libp2p/go-libp2p-net" ma "github.com/multiformats/go-multiaddr" ) @@ -18,17 +16,19 @@ func (p *PubSubNotif) ClosedStream(n inet.Network, s inet.Stream) { } func (p *PubSubNotif) Connected(n inet.Network, c inet.Conn) { - s, err := p.host.NewStream(context.Background(), c.RemotePeer(), ID) - if err != nil { - log.Warning("opening new stream to peer: ", err, c.LocalPeer(), c.RemotePeer()) - return - } + go func() { + s, err := p.host.NewStream(p.ctx, c.RemotePeer(), ID) + if err != nil { + log.Warning("opening new stream to peer: ", err, c.LocalPeer(), c.RemotePeer()) + return + } - select { - case p.newPeers <- s: - case <-p.ctx.Done(): - s.Close() - } + select { + case p.newPeers <- s: + case <-p.ctx.Done(): + s.Close() + } + }() } func (p *PubSubNotif) Disconnected(n inet.Network, c inet.Conn) { From c9d7fd9e1440c420829162fe6380624cb4273af7 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 27 Jul 2017 18:46:01 -0700 Subject: [PATCH 2/3] gx publish 0.8.17 --- .gx/lastpubver | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gx/lastpubver b/.gx/lastpubver index afa7391..3d9204e 100644 --- a/.gx/lastpubver +++ b/.gx/lastpubver @@ -1 +1 @@ -0.8.16: QmatoKaefBS5hopnDyMqZUgCjbBRPEi4ktZP5FVruiczbB +0.8.17: QmYFCNMYp7fR9p2pHDXPGtawfoAYEwrR9GLQbihkB96Krs diff --git a/package.json b/package.json index a6d07a0..2981b21 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,6 @@ "license": "", "name": "floodsub", "releaseCmd": "git commit -a -m \"gx publish $VERSION\"", - "version": "0.8.16" + "version": "0.8.17" } From ccedba1374abcfd56ce7e01e73b066495dc2cfc8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 27 Jul 2017 18:57:32 -0700 Subject: [PATCH 3/3] ci: update travis to go 1.8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 008af4e..46392bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ os: language: go go: - - 1.7 + - 1.8 install: true