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
p2p
go-yamux
Commits
67e9bf6d
Unverified
Commit
67e9bf6d
authored
Feb 17, 2021
by
Marten Seemann
Committed by
GitHub
Feb 17, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #42 from libp2p/remove-recv-lock
remove the recvLock in the stream
parents
4e665e89
5432a246
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
6 deletions
+2
-6
stream.go
stream.go
+2
-6
No files found.
stream.go
View file @
67e9bf6d
...
@@ -37,8 +37,7 @@ type Stream struct {
...
@@ -37,8 +37,7 @@ type Stream struct {
writeState
,
readState
halfStreamState
writeState
,
readState
halfStreamState
stateLock
sync
.
Mutex
stateLock
sync
.
Mutex
recvLock
sync
.
Mutex
recvBuf
segmentedBuffer
recvBuf
segmentedBuffer
recvNotifyCh
chan
struct
{}
recvNotifyCh
chan
struct
{}
sendNotifyCh
chan
struct
{}
sendNotifyCh
chan
struct
{}
...
@@ -97,9 +96,7 @@ START:
...
@@ -97,9 +96,7 @@ START:
}
}
// If there is no data available, block
// If there is no data available, block
s
.
recvLock
.
Lock
()
if
s
.
recvBuf
.
Len
()
==
0
{
if
s
.
recvBuf
.
Len
()
==
0
{
s
.
recvLock
.
Unlock
()
select
{
select
{
case
<-
s
.
recvNotifyCh
:
case
<-
s
.
recvNotifyCh
:
goto
START
goto
START
...
@@ -110,7 +107,6 @@ START:
...
@@ -110,7 +107,6 @@ START:
// Read any bytes
// Read any bytes
n
,
_
=
s
.
recvBuf
.
Read
(
b
)
n
,
_
=
s
.
recvBuf
.
Read
(
b
)
s
.
recvLock
.
Unlock
()
// Send a window update potentially
// Send a window update potentially
err
=
s
.
sendWindowUpdate
()
err
=
s
.
sendWindowUpdate
()
...
@@ -437,7 +433,7 @@ func (s *Stream) readData(hdr header, flags uint16, conn io.Reader) error {
...
@@ -437,7 +433,7 @@ func (s *Stream) readData(hdr header, flags uint16, conn io.Reader) error {
s
.
session
.
logger
.
Printf
(
"[ERR] yamux: Failed to read stream data: %v"
,
err
)
s
.
session
.
logger
.
Printf
(
"[ERR] yamux: Failed to read stream data: %v"
,
err
)
return
err
return
err
}
}
// Unblock
any
reader
s
// Unblock
the
reader
asyncNotify
(
s
.
recvNotifyCh
)
asyncNotify
(
s
.
recvNotifyCh
)
return
nil
return
nil
}
}
...
...
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