mirror of
https://github.com/moparisthebest/spdylay
synced 2024-12-21 23:28:52 -05:00
Added spdylay_session_get_outbound_queue_size()
This commit is contained in:
parent
b8e4116f9a
commit
8f038ae4b6
@ -1199,6 +1199,14 @@ int spdylay_session_want_write(spdylay_session *session);
|
|||||||
void* spdylay_session_get_stream_user_data(spdylay_session *session,
|
void* spdylay_session_get_stream_user_data(spdylay_session *session,
|
||||||
int32_t stream_id);
|
int32_t stream_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* Returns the number of frames in the outbound queue. This does not
|
||||||
|
* include the deferred DATA frames.
|
||||||
|
*/
|
||||||
|
size_t spdylay_session_get_outbound_queue_size(spdylay_session *session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
*
|
*
|
||||||
|
@ -120,3 +120,8 @@ int spdylay_pq_empty(spdylay_pq *pq)
|
|||||||
{
|
{
|
||||||
return pq->length == 0;
|
return pq->length == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t spdylay_pq_size(spdylay_pq *pq)
|
||||||
|
{
|
||||||
|
return pq->length;
|
||||||
|
}
|
||||||
|
@ -91,4 +91,9 @@ void spdylay_pq_pop(spdylay_pq *pq);
|
|||||||
*/
|
*/
|
||||||
int spdylay_pq_empty(spdylay_pq *pq);
|
int spdylay_pq_empty(spdylay_pq *pq);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the number of items in the queue |pq|.
|
||||||
|
*/
|
||||||
|
size_t spdylay_pq_size(spdylay_pq *pq);
|
||||||
|
|
||||||
#endif /* SPDYLAY_PQ_H */
|
#endif /* SPDYLAY_PQ_H */
|
||||||
|
@ -2346,3 +2346,8 @@ uint8_t spdylay_session_get_pri_lowest(spdylay_session *session)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t spdylay_session_get_outbound_queue_size(spdylay_session *session)
|
||||||
|
{
|
||||||
|
return spdylay_pq_size(&session->ob_pq)+spdylay_pq_size(&session->ob_ss_pq);
|
||||||
|
}
|
||||||
|
@ -142,6 +142,8 @@ int main(int argc, char* argv[])
|
|||||||
test_spdylay_session_on_settings_received) ||
|
test_spdylay_session_on_settings_received) ||
|
||||||
!CU_add_test(pSuite, "session_submit_settings",
|
!CU_add_test(pSuite, "session_submit_settings",
|
||||||
test_spdylay_submit_settings) ||
|
test_spdylay_submit_settings) ||
|
||||||
|
!CU_add_test(pSuite, "session_get_outbound_queue_size",
|
||||||
|
test_spdylay_session_get_outbound_queue_size) ||
|
||||||
!CU_add_test(pSuite, "frame_unpack_nv_spdy2",
|
!CU_add_test(pSuite, "frame_unpack_nv_spdy2",
|
||||||
test_spdylay_frame_unpack_nv_spdy2) ||
|
test_spdylay_frame_unpack_nv_spdy2) ||
|
||||||
!CU_add_test(pSuite, "frame_unpack_nv_spdy3",
|
!CU_add_test(pSuite, "frame_unpack_nv_spdy3",
|
||||||
|
@ -37,21 +37,29 @@ void test_spdylay_pq()
|
|||||||
{
|
{
|
||||||
spdylay_pq pq;
|
spdylay_pq pq;
|
||||||
spdylay_pq_init(&pq, pq_compar);
|
spdylay_pq_init(&pq, pq_compar);
|
||||||
|
CU_ASSERT(spdylay_pq_empty(&pq));
|
||||||
|
CU_ASSERT(0 == spdylay_pq_size(&pq));
|
||||||
CU_ASSERT(0 == spdylay_pq_push(&pq, "foo"));
|
CU_ASSERT(0 == spdylay_pq_push(&pq, "foo"));
|
||||||
|
CU_ASSERT(0 == spdylay_pq_empty(&pq));
|
||||||
|
CU_ASSERT(1 == spdylay_pq_size(&pq));
|
||||||
CU_ASSERT(strcmp("foo", spdylay_pq_top(&pq)) == 0);
|
CU_ASSERT(strcmp("foo", spdylay_pq_top(&pq)) == 0);
|
||||||
CU_ASSERT(0 == spdylay_pq_push(&pq, "bar"));
|
CU_ASSERT(0 == spdylay_pq_push(&pq, "bar"));
|
||||||
CU_ASSERT(strcmp("bar", spdylay_pq_top(&pq)) == 0);
|
CU_ASSERT(strcmp("bar", spdylay_pq_top(&pq)) == 0);
|
||||||
CU_ASSERT(0 == spdylay_pq_push(&pq, "baz"));
|
CU_ASSERT(0 == spdylay_pq_push(&pq, "baz"));
|
||||||
CU_ASSERT(strcmp("bar", spdylay_pq_top(&pq)) == 0);
|
CU_ASSERT(strcmp("bar", spdylay_pq_top(&pq)) == 0);
|
||||||
CU_ASSERT(0 == spdylay_pq_push(&pq, "C"));
|
CU_ASSERT(0 == spdylay_pq_push(&pq, "C"));
|
||||||
|
CU_ASSERT(4 == spdylay_pq_size(&pq));
|
||||||
CU_ASSERT(strcmp("C", spdylay_pq_top(&pq)) == 0);
|
CU_ASSERT(strcmp("C", spdylay_pq_top(&pq)) == 0);
|
||||||
spdylay_pq_pop(&pq);
|
spdylay_pq_pop(&pq);
|
||||||
|
CU_ASSERT(3 == spdylay_pq_size(&pq));
|
||||||
CU_ASSERT(strcmp("bar", spdylay_pq_top(&pq)) == 0);
|
CU_ASSERT(strcmp("bar", spdylay_pq_top(&pq)) == 0);
|
||||||
spdylay_pq_pop(&pq);
|
spdylay_pq_pop(&pq);
|
||||||
CU_ASSERT(strcmp("baz", spdylay_pq_top(&pq)) == 0);
|
CU_ASSERT(strcmp("baz", spdylay_pq_top(&pq)) == 0);
|
||||||
spdylay_pq_pop(&pq);
|
spdylay_pq_pop(&pq);
|
||||||
CU_ASSERT(strcmp("foo", spdylay_pq_top(&pq)) == 0);
|
CU_ASSERT(strcmp("foo", spdylay_pq_top(&pq)) == 0);
|
||||||
spdylay_pq_pop(&pq);
|
spdylay_pq_pop(&pq);
|
||||||
|
CU_ASSERT(spdylay_pq_empty(&pq));
|
||||||
|
CU_ASSERT(0 == spdylay_pq_size(&pq));
|
||||||
CU_ASSERT(0 == spdylay_pq_top(&pq));
|
CU_ASSERT(0 == spdylay_pq_top(&pq));
|
||||||
spdylay_pq_free(&pq);
|
spdylay_pq_free(&pq);
|
||||||
}
|
}
|
||||||
|
@ -2022,3 +2022,22 @@ void test_spdylay_submit_settings()
|
|||||||
|
|
||||||
spdylay_session_del(session);
|
spdylay_session_del(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_spdylay_session_get_outbound_queue_size()
|
||||||
|
{
|
||||||
|
spdylay_session *session;
|
||||||
|
spdylay_session_callbacks callbacks;
|
||||||
|
const char *nv[] = { "version", "HTTP/1.1", NULL };
|
||||||
|
|
||||||
|
memset(&callbacks, 0, sizeof(spdylay_session_callbacks));
|
||||||
|
CU_ASSERT(0 == spdylay_session_client_new(&session, SPDYLAY_PROTO_SPDY3,
|
||||||
|
&callbacks, NULL));
|
||||||
|
CU_ASSERT(0 == spdylay_session_get_outbound_queue_size(session));
|
||||||
|
|
||||||
|
CU_ASSERT(0 == spdylay_submit_syn_stream(session, SPDYLAY_CTRL_FLAG_FIN, 1, 7,
|
||||||
|
nv, NULL));
|
||||||
|
CU_ASSERT(1 == spdylay_session_get_outbound_queue_size(session));
|
||||||
|
|
||||||
|
CU_ASSERT(0 == spdylay_submit_goaway(session, SPDYLAY_GOAWAY_OK));
|
||||||
|
CU_ASSERT(2 == spdylay_session_get_outbound_queue_size(session));
|
||||||
|
}
|
||||||
|
@ -63,5 +63,6 @@ void test_spdylay_session_flow_control();
|
|||||||
void test_spdylay_session_on_ctrl_not_send();
|
void test_spdylay_session_on_ctrl_not_send();
|
||||||
void test_spdylay_session_on_settings_received();
|
void test_spdylay_session_on_settings_received();
|
||||||
void test_spdylay_submit_settings();
|
void test_spdylay_submit_settings();
|
||||||
|
void test_spdylay_session_get_outbound_queue_size();
|
||||||
|
|
||||||
#endif // SPDYLAY_SESSION_TEST_H
|
#endif // SPDYLAY_SESSION_TEST_H
|
||||||
|
Loading…
Reference in New Issue
Block a user