Fix: save an allocation when a stream ends.

This commit is contained in:
Yifu Yu 2024-03-02 01:25:15 +08:00
parent 4bb97ee43a
commit fed6b92227
1 changed files with 1 additions and 1 deletions

View File

@ -143,11 +143,11 @@ func upstreamFiber(name string) {
})() })()
body := r.Body body := r.Body
for { for {
buff := make([]byte, 65536)
if ctx.viewer == 0 { if ctx.viewer == 0 {
fmt.Printf("No active viewers for %s, stopping reading from upstream.\n", name) fmt.Printf("No active viewers for %s, stopping reading from upstream.\n", name)
break break
} }
buff := make([]byte, 65536)
n, err := body.Read(buff) n, err := body.Read(buff)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "Upstream for stream %s request reached EOF\n", name) fmt.Fprintf(os.Stderr, "Upstream for stream %s request reached EOF\n", name)