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
1fd68ed7
Commit
1fd68ed7
authored
Aug 27, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sessionmanager: allow concurrent receive/wanted checks
parent
863aa22c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
sessionmanager/sessionmanager.go
sessionmanager/sessionmanager.go
+5
-5
No files found.
sessionmanager/sessionmanager.go
View file @
1fd68ed7
...
...
@@ -46,7 +46,7 @@ type SessionManager struct {
notif
notifications
.
PubSub
// Sessions
sessLk
sync
.
Mutex
sessLk
sync
.
RW
Mutex
sessions
[]
sesTrk
// Session Index
...
...
@@ -117,8 +117,8 @@ func (sm *SessionManager) GetNextSessionID() uint64 {
// ReceiveFrom receives block CIDs from a peer and dispatches to sessions.
func
(
sm
*
SessionManager
)
ReceiveFrom
(
from
peer
.
ID
,
ks
[]
cid
.
Cid
)
{
sm
.
sessLk
.
Lock
()
defer
sm
.
sessLk
.
Unlock
()
sm
.
sessLk
.
R
Lock
()
defer
sm
.
sessLk
.
R
Unlock
()
for
_
,
s
:=
range
sm
.
sessions
{
s
.
session
.
ReceiveFrom
(
from
,
ks
)
...
...
@@ -128,8 +128,8 @@ func (sm *SessionManager) ReceiveFrom(from peer.ID, ks []cid.Cid) {
// IsWanted indicates whether any of the sessions are waiting to receive
// the block with the given CID.
func
(
sm
*
SessionManager
)
IsWanted
(
cid
cid
.
Cid
)
bool
{
sm
.
sessLk
.
Lock
()
defer
sm
.
sessLk
.
Unlock
()
sm
.
sessLk
.
R
Lock
()
defer
sm
.
sessLk
.
R
Unlock
()
for
_
,
s
:=
range
sm
.
sessions
{
if
s
.
session
.
IsWanted
(
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