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
25318da3
Unverified
Commit
25318da3
authored
Jun 09, 2020
by
Steven Allen
Committed by
GitHub
Jun 09, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #412 from ipfs/fix/race
fix: avoid taking accessing the peerQueues without taking the lock
parents
3ab1ede0
69e72e4d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
9 additions
and
15 deletions
+9
-15
.circleci/config.yml
.circleci/config.yml
+4
-4
internal/peermanager/peermanager.go
internal/peermanager/peermanager.go
+1
-4
internal/session/session.go
internal/session/session.go
+1
-1
internal/session/session_test.go
internal/session/session_test.go
+1
-3
internal/session/sessionwantsender_test.go
internal/session/sessionwantsender_test.go
+1
-2
internal/sessionmanager/sessionmanager_test.go
internal/sessionmanager/sessionmanager_test.go
+1
-1
No files found.
.circleci/config.yml
View file @
25318da3
...
...
@@ -12,7 +12,7 @@ workflows:
-
ci-go/test
:
race
:
true
name
:
"
ci-go/test/race"
-
ci-go/benchmark
:
tolerance
:
50
requires
:
-
ci-go/test
#
- ci-go/benchmark:
#
tolerance: 50
#
requires:
#
- ci-go/test
internal/peermanager/peermanager.go
View file @
25318da3
...
...
@@ -198,7 +198,7 @@ func (pm *PeerManager) getOrCreate(p peer.ID) PeerQueue {
// RegisterSession tells the PeerManager that the given session is interested
// in events about the given peer.
func
(
pm
*
PeerManager
)
RegisterSession
(
p
peer
.
ID
,
s
Session
)
bool
{
func
(
pm
*
PeerManager
)
RegisterSession
(
p
peer
.
ID
,
s
Session
)
{
pm
.
psLk
.
Lock
()
defer
pm
.
psLk
.
Unlock
()
...
...
@@ -210,9 +210,6 @@ func (pm *PeerManager) RegisterSession(p peer.ID, s Session) bool {
pm
.
peerSessions
[
p
]
=
make
(
map
[
uint64
]
struct
{})
}
pm
.
peerSessions
[
p
][
s
.
ID
()]
=
struct
{}{}
_
,
ok
:=
pm
.
peerQueues
[
p
]
return
ok
}
// UnregisterSession tells the PeerManager that the given session is no longer
...
...
internal/session/session.go
View file @
25318da3
...
...
@@ -30,7 +30,7 @@ const (
type
PeerManager
interface
{
// RegisterSession tells the PeerManager that the session is interested
// in a peer's connection state
RegisterSession
(
peer
.
ID
,
bspm
.
Session
)
bool
RegisterSession
(
peer
.
ID
,
bspm
.
Session
)
// UnregisterSession tells the PeerManager that the session is no longer
// interested in a peer's connection state
UnregisterSession
(
uint64
)
...
...
internal/session/session_test.go
View file @
25318da3
...
...
@@ -136,9 +136,7 @@ func newFakePeerManager() *fakePeerManager {
}
}
func
(
pm
*
fakePeerManager
)
RegisterSession
(
peer
.
ID
,
bspm
.
Session
)
bool
{
return
true
}
func
(
pm
*
fakePeerManager
)
RegisterSession
(
peer
.
ID
,
bspm
.
Session
)
{}
func
(
pm
*
fakePeerManager
)
UnregisterSession
(
uint64
)
{}
func
(
pm
*
fakePeerManager
)
SendWants
(
context
.
Context
,
peer
.
ID
,
[]
cid
.
Cid
,
[]
cid
.
Cid
)
{}
func
(
pm
*
fakePeerManager
)
BroadcastWantHaves
(
ctx
context
.
Context
,
cids
[]
cid
.
Cid
)
{
...
...
internal/session/sessionwantsender_test.go
View file @
25318da3
...
...
@@ -59,12 +59,11 @@ func newMockPeerManager() *mockPeerManager {
}
}
func
(
pm
*
mockPeerManager
)
RegisterSession
(
p
peer
.
ID
,
sess
bspm
.
Session
)
bool
{
func
(
pm
*
mockPeerManager
)
RegisterSession
(
p
peer
.
ID
,
sess
bspm
.
Session
)
{
pm
.
lk
.
Lock
()
defer
pm
.
lk
.
Unlock
()
pm
.
peerSessions
[
p
]
=
sess
return
true
}
func
(
pm
*
mockPeerManager
)
has
(
p
peer
.
ID
,
sid
uint64
)
bool
{
...
...
internal/sessionmanager/sessionmanager_test.go
View file @
25318da3
...
...
@@ -64,7 +64,7 @@ type fakePeerManager struct {
cancels
[]
cid
.
Cid
}
func
(
*
fakePeerManager
)
RegisterSession
(
peer
.
ID
,
bspm
.
Session
)
bool
{
return
true
}
func
(
*
fakePeerManager
)
RegisterSession
(
peer
.
ID
,
bspm
.
Session
)
{
}
func
(
*
fakePeerManager
)
UnregisterSession
(
uint64
)
{}
func
(
*
fakePeerManager
)
SendWants
(
context
.
Context
,
peer
.
ID
,
[]
cid
.
Cid
,
[]
cid
.
Cid
)
{}
func
(
*
fakePeerManager
)
BroadcastWantHaves
(
context
.
Context
,
[]
cid
.
Cid
)
{}
...
...
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