Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
542d43a3
Unverified
Commit
542d43a3
authored
Sep 10, 2018
by
Steven Allen
Committed by
GitHub
Sep 10, 2018
Browse files
Merge pull request #420 from libp2p/fix/419
always remove connection from identify service map
parents
fe20b1dd
e436bcc3
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/protocol/identify/id.go
View file @
542d43a3
...
...
@@ -83,7 +83,12 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
ids
.
currid
[
c
]
=
ch
ids
.
currmu
.
Unlock
()
defer
close
(
ch
)
defer
func
()
{
close
(
ch
)
ids
.
currmu
.
Lock
()
delete
(
ids
.
currid
,
c
)
ids
.
currmu
.
Unlock
()
}()
s
,
err
:=
c
.
NewStream
()
if
err
!=
nil
{
...
...
@@ -103,16 +108,6 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
}
ids
.
responseHandler
(
s
)
ids
.
currmu
.
Lock
()
_
,
found
:=
ids
.
currid
[
c
]
delete
(
ids
.
currid
,
c
)
ids
.
currmu
.
Unlock
()
if
!
found
{
log
.
Errorf
(
"IdentifyConn failed to find channel (programmer error) for %s"
,
c
)
}
inet
.
FullClose
(
s
)
}
func
(
ids
*
IDService
)
requestHandler
(
s
inet
.
Stream
)
{
...
...
@@ -135,12 +130,14 @@ func (ids *IDService) responseHandler(s inet.Stream) {
mes
:=
pb
.
Identify
{}
if
err
:=
r
.
ReadMsg
(
&
mes
);
err
!=
nil
{
log
.
Warning
(
"error reading identify message: "
,
err
)
s
.
Reset
()
return
}
ids
.
consumeMessage
(
&
mes
,
c
)
log
.
Debugf
(
"%s received message from %s %s"
,
ID
,
c
.
RemotePeer
(),
c
.
RemoteMultiaddr
())
go
inet
.
FullClose
(
s
)
}
func
(
ids
*
IDService
)
populateMessage
(
mes
*
pb
.
Identify
,
c
inet
.
Conn
)
{
...
...
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