Added seq sort key in ob_pq to preserve the queueing order if priorit is the same.
This commit is contained in:
parent
4e192493ab
commit
49096387c3
|
@ -58,7 +58,11 @@ int spdylay_outbound_item_compar(const void *lhsx, const void *rhsx)
|
||||||
const spdylay_outbound_item *lhs, *rhs;
|
const spdylay_outbound_item *lhs, *rhs;
|
||||||
lhs = (const spdylay_outbound_item*)lhsx;
|
lhs = (const spdylay_outbound_item*)lhsx;
|
||||||
rhs = (const spdylay_outbound_item*)rhsx;
|
rhs = (const spdylay_outbound_item*)rhsx;
|
||||||
|
if(lhs->pri == rhs->pri) {
|
||||||
|
return (lhs->seq < rhs->seq) ? -1 : ((lhs->seq > rhs->seq) ? 1 : 0);
|
||||||
|
} else {
|
||||||
return lhs->pri-rhs->pri;
|
return lhs->pri-rhs->pri;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int spdylay_session_client_new(spdylay_session **session_ptr,
|
int spdylay_session_client_new(spdylay_session **session_ptr,
|
||||||
|
@ -79,6 +83,8 @@ int spdylay_session_client_new(spdylay_session **session_ptr,
|
||||||
|
|
||||||
(*session_ptr)->last_ping_unique_id = 0;
|
(*session_ptr)->last_ping_unique_id = 0;
|
||||||
|
|
||||||
|
(*session_ptr)->next_seq = 0;
|
||||||
|
|
||||||
(*session_ptr)->goaway_flags = SPDYLAY_GOAWAY_NONE;
|
(*session_ptr)->goaway_flags = SPDYLAY_GOAWAY_NONE;
|
||||||
(*session_ptr)->last_good_stream_id = 0;
|
(*session_ptr)->last_good_stream_id = 0;
|
||||||
|
|
||||||
|
@ -192,6 +198,7 @@ int spdylay_session_add_frame(spdylay_session *session,
|
||||||
item->frame_type = frame_type;
|
item->frame_type = frame_type;
|
||||||
item->frame = frame;
|
item->frame = frame;
|
||||||
item->aux_data = aux_data;
|
item->aux_data = aux_data;
|
||||||
|
item->seq = session->next_seq++;
|
||||||
/* Set priority lowest at the moment. */
|
/* Set priority lowest at the moment. */
|
||||||
item->pri = 3;
|
item->pri = 3;
|
||||||
switch(frame_type) {
|
switch(frame_type) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ typedef struct {
|
||||||
spdylay_frame *frame;
|
spdylay_frame *frame;
|
||||||
void *aux_data;
|
void *aux_data;
|
||||||
int pri;
|
int pri;
|
||||||
|
int64_t seq;
|
||||||
} spdylay_outbound_item;
|
} spdylay_outbound_item;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -94,6 +95,10 @@ struct spdylay_session {
|
||||||
SPDYLAY_MAX_UNIQUE_ID */
|
SPDYLAY_MAX_UNIQUE_ID */
|
||||||
uint32_t next_unique_id;
|
uint32_t next_unique_id;
|
||||||
|
|
||||||
|
/* Sequence number of outbound frame to maintain the order of
|
||||||
|
enqueue if priority is equal. */
|
||||||
|
int64_t next_seq;
|
||||||
|
|
||||||
spdylay_map /* <spdylay_stream*> */ streams;
|
spdylay_map /* <spdylay_stream*> */ streams;
|
||||||
spdylay_pq /* <spdylay_outbound_item*> */ ob_pq;
|
spdylay_pq /* <spdylay_outbound_item*> */ ob_pq;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue