Unverified Commit e8e3876e authored by Marten Seemann's avatar Marten Seemann Committed by GitHub

Merge pull request #40 from libp2p/reduce-goto-usage

reduce usage of goto
parents 4847d7c7 a1b9bdb6
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment