Lower priority by constant value

This commit is contained in:
Tatsuhiro Tsujikawa 2013-12-11 23:20:59 +09:00
parent 9d49f9a356
commit e17f888944
2 changed files with 5 additions and 9 deletions

View File

@ -53,8 +53,6 @@ typedef struct {
int32_t pri; int32_t pri;
/* The initial priority */ /* The initial priority */
int32_t inipri; int32_t inipri;
/* The amount of priority decrement in next time */
uint32_t pri_decay;
} nghttp2_outbound_item; } nghttp2_outbound_item;
/* /*

View File

@ -474,7 +474,6 @@ int nghttp2_session_add_frame(nghttp2_session *session,
item->seq = session->next_seq++; item->seq = session->next_seq++;
/* Set priority to the default value at the moment. */ /* Set priority to the default value at the moment. */
item->pri = NGHTTP2_PRI_DEFAULT; item->pri = NGHTTP2_PRI_DEFAULT;
item->pri_decay = 1;
if(frame_cat == NGHTTP2_CAT_CTRL) { if(frame_cat == NGHTTP2_CAT_CTRL) {
nghttp2_frame *frame = (nghttp2_frame*)abs_frame; nghttp2_frame *frame = (nghttp2_frame*)abs_frame;
nghttp2_stream *stream = NULL; nghttp2_stream *stream = NULL;
@ -1390,25 +1389,24 @@ 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 * Adjust priority of the |item|. In order to prevent the low priority
* streams from starving, lower the priority of the |item| by * streams from starving, lower the priority of the |item| by a
* item->pri_decay. If the resulting priority exceeds * constant value. If the resulting priority exceeds
* NGHTTP2_PRI_DEFAULT, back to the original priority. * NGHTTP2_PRI_DEFAULT, back to the original priority.
*/ */
static void adjust_pri(nghttp2_outbound_item *item) static void adjust_pri(nghttp2_outbound_item *item)
{ {
if(item->pri == NGHTTP2_PRI_LOWEST) { if(item->pri == NGHTTP2_PRI_LOWEST) {
item->pri = item->inipri; item->pri = item->inipri;
item->pri_decay = 1;
return; return;
} }
if(item->pri > (int32_t)(NGHTTP2_PRI_LOWEST - (item->pri_decay - 1))) { if(item->pri > (int32_t)(NGHTTP2_PRI_LOWEST - NGHTTP2_PRI_DECAY)) {
item->pri = NGHTTP2_PRI_LOWEST; item->pri = NGHTTP2_PRI_LOWEST;
return; return;
} }
item->pri += (int32_t)(item->pri_decay - 1); item->pri += NGHTTP2_PRI_DECAY;
item->pri_decay <<= 1;
} }
/* /*