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
dms3
go-bitswap
Commits
ff038ecf
Commit
ff038ecf
authored
Oct 11, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix random bitswap hangs
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
a06e4b5d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
wantmanager.go
wantmanager.go
+11
-3
No files found.
wantmanager.go
View file @
ff038ecf
...
...
@@ -56,6 +56,8 @@ type msgQueue struct {
out
bsmsg
.
BitSwapMessage
network
bsnet
.
BitSwapNetwork
refcnt
int
work
chan
struct
{}
done
chan
struct
{}
}
...
...
@@ -101,13 +103,13 @@ func (pm *WantManager) SendBlock(ctx context.Context, env *engine.Envelope) {
}
func
(
pm
*
WantManager
)
startPeerHandler
(
p
peer
.
ID
)
*
msgQueue
{
_
,
ok
:=
pm
.
peers
[
p
]
mq
,
ok
:=
pm
.
peers
[
p
]
if
ok
{
// TODO: log an error?
mq
.
refcnt
++
return
nil
}
mq
:
=
pm
.
newMsgQueue
(
p
)
mq
=
pm
.
newMsgQueue
(
p
)
// new peer, we will want to give them our full wantlist
fullwantlist
:=
bsmsg
.
New
(
true
)
...
...
@@ -129,6 +131,11 @@ func (pm *WantManager) stopPeerHandler(p peer.ID) {
return
}
pq
.
refcnt
--
if
pq
.
refcnt
>
0
{
return
}
close
(
pq
.
done
)
delete
(
pm
.
peers
,
p
)
}
...
...
@@ -247,6 +254,7 @@ func (wm *WantManager) newMsgQueue(p peer.ID) *msgQueue {
mq
.
work
=
make
(
chan
struct
{},
1
)
mq
.
network
=
wm
.
network
mq
.
p
=
p
mq
.
refcnt
=
1
return
mq
}
...
...
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