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-ws-transport
Commits
b84e264b
Commit
b84e264b
authored
Sep 17, 2019
by
Alex Browne
Committed by
Steven Allen
Sep 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify Conn.Read logic
parent
aa28843d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
conn_browser.go
conn_browser.go
+14
-15
No files found.
conn_browser.go
View file @
b84e264b
...
...
@@ -64,22 +64,21 @@ func (c *Conn) Read(b []byte) (int, error) {
for
{
c
.
currDataMut
.
RLock
()
n
,
err
:=
c
.
currData
.
Read
(
b
)
n
,
_
:=
c
.
currData
.
Read
(
b
)
c
.
currDataMut
.
RUnlock
()
if
err
!=
nil
&&
err
!=
io
.
EOF
{
// Return any unexpected errors immediately.
return
n
,
err
}
else
if
n
==
0
||
err
==
io
.
EOF
{
// There is no data ready to be read. Wait for more data or for the
// connection to be closed.
select
{
case
<-
c
.
dataSignal
:
continue
case
<-
c
.
closeSignal
:
return
c
.
readAfterErr
(
b
)
}
}
else
{
return
n
,
err
if
n
!=
0
{
// Data was ready. Return the number of bytes read.
return
n
,
nil
}
// There is no data ready to be read. Wait for more data or for the
// connection to be closed.
select
{
case
<-
c
.
dataSignal
:
continue
case
<-
c
.
closeSignal
:
return
c
.
readAfterErr
(
b
)
}
}
}
...
...
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