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
e8e3876e
Unverified
Commit
e8e3876e
authored
Feb 16, 2021
by
Marten Seemann
Committed by
GitHub
Feb 16, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #40 from libp2p/reduce-goto-usage
reduce usage of goto
parents
4847d7c7
a1b9bdb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
18 deletions
+12
-18
stream.go
stream.go
+12
-18
No files found.
stream.go
View file @
e8e3876e
...
...
@@ -102,7 +102,12 @@ START:
s
.
recvLock
.
Lock
()
if
s
.
recvBuf
.
Len
()
==
0
{
s
.
recvLock
.
Unlock
()
goto
WAIT
select
{
case
<-
s
.
recvNotifyCh
:
goto
START
case
<-
s
.
readDeadline
.
wait
()
:
return
0
,
ErrTimeout
}
}
// Read any bytes
...
...
@@ -112,14 +117,6 @@ START:
// Send a window update potentially
err
=
s
.
sendWindowUpdate
()
return
n
,
err
WAIT
:
select
{
case
<-
s
.
recvNotifyCh
:
goto
START
case
<-
s
.
readDeadline
.
wait
()
:
return
0
,
ErrTimeout
}
}
// Write is used to write to the stream
...
...
@@ -164,7 +161,12 @@ START:
// If there is no data available, block
window
:=
atomic
.
LoadUint32
(
&
s
.
sendWindow
)
if
window
==
0
{
goto
WAIT
select
{
case
<-
s
.
sendNotifyCh
:
goto
START
case
<-
s
.
writeDeadline
.
wait
()
:
return
0
,
ErrTimeout
}
}
// Determine the flags if any
...
...
@@ -184,14 +186,6 @@ START:
// Unlock
return
int
(
max
),
err
WAIT
:
select
{
case
<-
s
.
sendNotifyCh
:
goto
START
case
<-
s
.
writeDeadline
.
wait
()
:
return
0
,
ErrTimeout
}
}
// sendFlags determines any flags that are appropriate
...
...
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