Commit 364501a2 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Get rid of magic value NGHTTP2_PRI_DECAY

For now we just double the priority value on each DATA frame
transmission. If priority is 0, it becomes to 1 and goes all
the way to (1 << 30) - 1.
parent f4ae707b
......@@ -1389,24 +1389,27 @@ nghttp2_outbound_item* nghttp2_session_pop_next_ob_item
}
}
#define NGHTTP2_PRI_DECAY (1 << 26)
/*
* Adjust priority of the |item|. In order to prevent the low priority
* streams from starving, lower the priority of the |item| by a
* constant value. If the resulting priority exceeds
* NGHTTP2_PRI_DEFAULT, back to the original priority.
* Adjust priority of the DATA frame |item|. In order to prevent the
* low priority streams from starving, lower the priority of the
* |item|. If the resulting priority exceeds NGHTTP2_PRI_DEFAULT,
* back to the original priority.
*/
static void adjust_pri(nghttp2_outbound_item *item)
static void adjust_data_pri(nghttp2_outbound_item *item)
{
if(item->pri == NGHTTP2_PRI_LOWEST) {
item->pri = item->inipri;
return;
}
if(item->pri > (int32_t)(NGHTTP2_PRI_LOWEST - NGHTTP2_PRI_DECAY)) {
if(item->pri & 0x40000000) {
item->pri = NGHTTP2_PRI_LOWEST;
return;
}
item->pri += NGHTTP2_PRI_DECAY;
if(item->pri == 0) {
item->pri = 1;
} else {
item->pri <<= 1;
}
}
/*
......@@ -1587,7 +1590,7 @@ static int nghttp2_session_after_frame_sent(nghttp2_session *session)
} else {
nghttp2_outbound_item* next_item;
next_item = nghttp2_session_get_next_ob_item(session);
adjust_pri(session->aob.item);
adjust_data_pri(session->aob.item);
/* If priority of this stream is higher or equal to other stream
waiting at the top of the queue, we continue to send this
data. */
......
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