mirror of
https://github.com/xtaci/smux.git
synced 2024-04-21 10:51:48 +00:00
ignore prio settinn in writeFrameInternal
This commit is contained in:
@@ -6,14 +6,8 @@ func _itimediff(later, earlier uint32) int32 {
|
||||
|
||||
type shaperHeap []writeRequest
|
||||
|
||||
func (h shaperHeap) Len() int { return len(h) }
|
||||
func (h shaperHeap) Less(i, j int) bool {
|
||||
if h[i].frame.sid == h[j].frame.sid {
|
||||
return _itimediff(h[j].seq, h[i].seq) > 0
|
||||
} else {
|
||||
return _itimediff(h[j].prio, h[i].prio) > 0
|
||||
}
|
||||
}
|
||||
func (h shaperHeap) Len() int { return len(h) }
|
||||
func (h shaperHeap) Less(i, j int) bool { return _itimediff(h[j].seq, h[i].seq) > 0 }
|
||||
func (h shaperHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
|
||||
func (h *shaperHeap) Push(x interface{}) { *h = append(*h, x.(writeRequest)) }
|
||||
|
||||
|
||||
@@ -30,3 +30,25 @@ func TestShaper(t *testing.T) {
|
||||
lastPrio = w.prio
|
||||
}
|
||||
}
|
||||
|
||||
func TestShaper2(t *testing.T) {
|
||||
w1 := writeRequest{prio: 10, seq: 1} // stream 0
|
||||
w2 := writeRequest{prio: 10, seq: 2}
|
||||
w3 := writeRequest{prio: 20, seq: 3}
|
||||
w4 := writeRequest{prio: 100, seq: 4}
|
||||
w5 := writeRequest{prio: (1 << 32) - 1, seq: 5}
|
||||
w6 := writeRequest{prio: 10, seq: 1, frame: Frame{sid: 10}} // stream 1
|
||||
|
||||
var reqs shaperHeap
|
||||
heap.Push(&reqs, w6)
|
||||
heap.Push(&reqs, w5)
|
||||
heap.Push(&reqs, w4)
|
||||
heap.Push(&reqs, w3)
|
||||
heap.Push(&reqs, w2)
|
||||
heap.Push(&reqs, w1)
|
||||
|
||||
for len(reqs) > 0 {
|
||||
w := heap.Pop(&reqs).(writeRequest)
|
||||
t.Log("prio:", w.prio, "sid:", w.frame.sid, "seq:", w.seq)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user