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
e6a2a408
Commit
e6a2a408
authored
Feb 20, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bitswap: fix stat data race
parent
13f4ed3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
bitswap.go
bitswap.go
+3
-2
bitswap_with_sessions_test.go
bitswap_with_sessions_test.go
+5
-1
No files found.
bitswap.go
View file @
e6a2a408
...
...
@@ -6,7 +6,6 @@ import (
"context"
"errors"
"sync"
"sync/atomic"
"time"
bssrs
"github.com/ipfs/go-bitswap/sessionrequestsplitter"
...
...
@@ -292,7 +291,9 @@ func (bs *Bitswap) receiveBlockFrom(blk blocks.Block, from peer.ID) error {
}
func
(
bs
*
Bitswap
)
ReceiveMessage
(
ctx
context
.
Context
,
p
peer
.
ID
,
incoming
bsmsg
.
BitSwapMessage
)
{
atomic
.
AddUint64
(
&
bs
.
counters
.
messagesRecvd
,
1
)
bs
.
counterLk
.
Lock
()
bs
.
counters
.
messagesRecvd
++
bs
.
counterLk
.
Unlock
()
// This call records changes to wantlists, blocks received,
// and number of bytes transfered.
...
...
bitswap_with_sessions_test.go
View file @
e6a2a408
...
...
@@ -104,7 +104,11 @@ func TestSessionBetweenPeers(t *testing.T) {
}
}
for
_
,
is
:=
range
inst
[
2
:
]
{
if
is
.
Exchange
.
counters
.
messagesRecvd
>
2
{
stat
,
err
:=
is
.
Exchange
.
Stat
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
stat
.
MessagesReceived
>
2
{
t
.
Fatal
(
"uninvolved nodes should only receive two messages"
,
is
.
Exchange
.
counters
.
messagesRecvd
)
}
}
...
...
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