Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kad-dht
Commits
13a847a8
Commit
13a847a8
authored
Jul 26, 2017
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix race condition where we might not close an opened stream.
parent
a1b973ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
notif.go
notif.go
+5
-8
No files found.
notif.go
View file @
13a847a8
...
...
@@ -55,24 +55,21 @@ func (nn *netNotifiee) Connected(n inet.Network, v inet.Conn) {
for
{
s
,
err
:=
dht
.
host
.
NewStream
(
ctx
,
v
.
RemotePeer
(),
ProtocolDHT
,
ProtocolDHTOld
)
// Canceled.
if
ctx
.
Err
()
!=
nil
{
return
}
switch
err
{
case
nil
:
s
.
Close
()
dht
.
plk
.
Lock
()
defer
dht
.
plk
.
Unlock
()
// Check if canceled
again
under the lock.
// Check if canceled under the lock.
if
ctx
.
Err
()
==
nil
{
dht
.
Update
(
dht
.
Context
(),
v
.
RemotePeer
())
}
case
io
.
EOF
:
// Connection died but we may still have *an* open connection so try again.
if
ctx
.
Err
()
==
nil
{
// Connection died but we may still have *an* open connection (context not canceled) so try again.
continue
}
case
mstream
.
ErrNotSupported
:
// Client mode only, don't bother adding them to our routing table
default
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment