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
e9edd9bd
Commit
e9edd9bd
authored
May 15, 2016
by
Jeromy Johnson
Browse files
Merge pull request #49 from ipfs/fix/id-hang
close wait channel in all cases, not just success
parents
ea5428f9
6dc5e19c
Changes
1
Show whitespace changes
Inline
Side-by-side
p2p/protocol/identify/id.go
View file @
e9edd9bd
...
@@ -72,9 +72,12 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
...
@@ -72,9 +72,12 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
<-
wait
// already identifying it. wait for it.
<-
wait
// already identifying it. wait for it.
return
return
}
}
ids
.
currid
[
c
]
=
make
(
chan
struct
{})
ch
:=
make
(
chan
struct
{})
ids
.
currid
[
c
]
=
ch
ids
.
currmu
.
Unlock
()
ids
.
currmu
.
Unlock
()
defer
close
(
ch
)
s
,
err
:=
c
.
NewStream
()
s
,
err
:=
c
.
NewStream
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Debugf
(
"error opening initial stream for %s: %s"
,
ID
,
err
)
log
.
Debugf
(
"error opening initial stream for %s: %s"
,
ID
,
err
)
...
@@ -97,7 +100,7 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
...
@@ -97,7 +100,7 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
ids
.
ResponseHandler
(
s
)
ids
.
ResponseHandler
(
s
)
ids
.
currmu
.
Lock
()
ids
.
currmu
.
Lock
()
ch
,
found
:=
ids
.
currid
[
c
]
_
,
found
:=
ids
.
currid
[
c
]
delete
(
ids
.
currid
,
c
)
delete
(
ids
.
currid
,
c
)
ids
.
currmu
.
Unlock
()
ids
.
currmu
.
Unlock
()
...
@@ -105,8 +108,6 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
...
@@ -105,8 +108,6 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
log
.
Debugf
(
"IdentifyConn failed to find channel (programmer error) for %s"
,
c
)
log
.
Debugf
(
"IdentifyConn failed to find channel (programmer error) for %s"
,
c
)
return
return
}
}
close
(
ch
)
// release everyone waiting.
}
}
func
(
ids
*
IDService
)
RequestHandler
(
s
inet
.
Stream
)
{
func
(
ids
*
IDService
)
RequestHandler
(
s
inet
.
Stream
)
{
...
...
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