Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions transport/internet/splithttp/upload_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ func (h *UploadQueue) Read(b []byte) (int, error) {
return 0, io.EOF
}

needMorePackets := false
if len(h.heap) == 0 {
packet, more := <-h.pushedPackets
if !more {
return 0, io.EOF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if EOF is handled here, I think line 50 can be removed? and then h.closed can be removed.

because h.pushedPackets is always closed when h.closed == true

}
heap.Push(&h.heap, packet)
}

if len(h.heap) > 0 {
for len(h.heap) > 0 {
packet := heap.Pop(&h.heap).(Packet)
n := 0

Expand Down Expand Up @@ -81,18 +87,12 @@ func (h *UploadQueue) Read(b []byte) (int, error) {
return 0, newError("packet queue is too large")
}
heap.Push(&h.heap, packet)
needMorePackets = true
}
} else {
needMorePackets = true
}

if needMorePackets {
packet, more := <-h.pushedPackets
if !more {
return 0, io.EOF
packet2, more := <-h.pushedPackets
if !more {
return 0, io.EOF
}
heap.Push(&h.heap, packet2)
}
heap.Push(&h.heap, packet)
}

return 0, nil
Expand Down