summaryrefslogtreecommitdiff
path: root/src/h2.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2022-04-17 20:39:34 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2022-05-05 13:35:18 -0400
commit59b9a9a73d1d47c72483e040b8a45dcdac05f4cd (patch)
treeff1910e60f1cb8cbfcc24e41817263060be9ea65 /src/h2.c
parentd48947ffa0dbf706076632fb8b894863dce54bab (diff)
downloadlighttpd-git-59b9a9a73d1d47c72483e040b8a45dcdac05f4cd.tar.gz
[core] h2 prio sort urgency, incr, then stream id
h2 priority sort based on urgency, incremental, then stream id
Diffstat (limited to 'src/h2.c')
-rw-r--r--src/h2.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/h2.c b/src/h2.c
index f8ea9489..7bc580b5 100644
--- a/src/h2.c
+++ b/src/h2.c
@@ -575,21 +575,29 @@ h2_recv_ping (connection * const con, uint8_t * const s, const uint32_t len)
static void
-h2_apply_priority_update (h2con * const h2c, request_st * const r, const uint32_t rpos)
+h2_apply_priority_update (h2con * const h2c, const request_st * const r, const uint32_t rpos)
{
+ const request_st ** const rr = (const request_st **)h2c->r;
uint32_t npos = rpos;
- while (npos && h2c->r[npos-1]->h2_prio > r->h2_prio) --npos;
+ while (npos
+ && (rr[npos-1]->h2_prio > r->h2_prio
+ || (rr[npos-1]->h2_prio == r->h2_prio
+ && rr[npos-1]->h2id > r->h2id)))
+ --npos;
if (rpos - npos) {
- memmove(h2c->r+npos+1, h2c->r+npos, (rpos - npos)*sizeof(request_st *));
+ memmove(rr+npos+1, rr+npos, (rpos - npos)*sizeof(request_st *));
}
else {
- while (npos+1 < h2c->rused && h2c->r[npos+1]->h2_prio <= r->h2_prio)
+ while (npos+1 < h2c->rused
+ && (rr[npos+1]->h2_prio < r->h2_prio
+ || (rr[npos+1]->h2_prio == r->h2_prio
+ && rr[npos+1]->h2id < r->h2id)))
++npos;
if (npos - rpos == 0)
return; /*(no movement)*/
- memmove(h2c->r+rpos, h2c->r+rpos+1, (npos - rpos)*sizeof(request_st *));
+ memmove(rr+rpos, rr+rpos+1, (npos - rpos)*sizeof(request_st *));
}
- h2c->r[npos] = r;
+ rr[npos] = r;
}