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
Hide 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 {
...
@@ -46,7 +46,7 @@ type SessionManager struct {
notif
notifications
.
PubSub
notif
notifications
.
PubSub
// Sessions
// Sessions
sessLk
sync
.
Mutex
sessLk
sync
.
RW
Mutex
sessions
[]
sesTrk
sessions
[]
sesTrk
// Session Index
// Session Index
...
@@ -117,8 +117,8 @@ func (sm *SessionManager) GetNextSessionID() uint64 {
...
@@ -117,8 +117,8 @@ func (sm *SessionManager) GetNextSessionID() uint64 {
// ReceiveFrom receives block CIDs from a peer and dispatches to sessions.
// ReceiveFrom receives block CIDs from a peer and dispatches to sessions.
func
(
sm
*
SessionManager
)
ReceiveFrom
(
from
peer
.
ID
,
ks
[]
cid
.
Cid
)
{
func
(
sm
*
SessionManager
)
ReceiveFrom
(
from
peer
.
ID
,
ks
[]
cid
.
Cid
)
{
sm
.
sessLk
.
Lock
()
sm
.
sessLk
.
R
Lock
()
defer
sm
.
sessLk
.
Unlock
()
defer
sm
.
sessLk
.
R
Unlock
()
for
_
,
s
:=
range
sm
.
sessions
{
for
_
,
s
:=
range
sm
.
sessions
{
s
.
session
.
ReceiveFrom
(
from
,
ks
)
s
.
session
.
ReceiveFrom
(
from
,
ks
)
...
@@ -128,8 +128,8 @@ func (sm *SessionManager) ReceiveFrom(from peer.ID, ks []cid.Cid) {
...
@@ -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
// IsWanted indicates whether any of the sessions are waiting to receive
// the block with the given CID.
// the block with the given CID.
func
(
sm
*
SessionManager
)
IsWanted
(
cid
cid
.
Cid
)
bool
{
func
(
sm
*
SessionManager
)
IsWanted
(
cid
cid
.
Cid
)
bool
{
sm
.
sessLk
.
Lock
()
sm
.
sessLk
.
R
Lock
()
defer
sm
.
sessLk
.
Unlock
()
defer
sm
.
sessLk
.
R
Unlock
()
for
_
,
s
:=
range
sm
.
sessions
{
for
_
,
s
:=
range
sm
.
sessions
{
if
s
.
session
.
IsWanted
(
cid
)
{
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