diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-06-23 15:42:33 +0100 |
---|---|---|
committer | Olivier Crête <olivier.crete@collabora.com> | 2016-06-03 18:35:36 -0400 |
commit | 11d4bb9783a69363de80ff49638030ba892a93fe (patch) | |
tree | afa5bfb9c793e3a4d67740729716c20908996ace /tests/test-pseudotcp-fin.c | |
parent | a9a149f529b3165543b52260d40a7855401841da (diff) | |
download | libnice-11d4bb9783a69363de80ff49638030ba892a93fe.tar.gz |
pseudotcp: Correct behaviour of buffer size methods when part-closed
Correct the behaviour of pseudo_tcp_socket_get_available_bytes() and
pseudo_tcp_get_available_send_space() when the socket is not in
TCP_ESTABLISHED state. It’s still permissible to send and receive up
until the local side calls pseudo_tcp_socket_close(), which means we
may be in state TCP_ESTABLISHED *or TCP_CLOSE_WAIT*.
Diffstat (limited to 'tests/test-pseudotcp-fin.c')
-rw-r--r-- | tests/test-pseudotcp-fin.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test-pseudotcp-fin.c b/tests/test-pseudotcp-fin.c index 4cc88aa..de5a910 100644 --- a/tests/test-pseudotcp-fin.c +++ b/tests/test-pseudotcp-fin.c @@ -1152,6 +1152,13 @@ pseudotcp_close_recv_queued (void) /* Establish a connection. */ establish_connection (&data); + g_assert_cmpint (pseudo_tcp_socket_get_available_bytes (data.left), ==, 0); + g_assert_cmpint (pseudo_tcp_socket_get_available_bytes (data.right), ==, 0); + g_assert_cmpint (pseudo_tcp_socket_get_available_send_space (data.right), >, + 0); + g_assert_cmpint (pseudo_tcp_socket_get_available_send_space (data.left), >, + 0); + g_assert_cmpint (pseudo_tcp_socket_send (data.left, "foo", 3), ==, 3); expect_data (data.left, data.left_sent, 7, 7, 3); forward_segment_ltr (&data); @@ -1164,9 +1171,24 @@ pseudotcp_close_recv_queued (void) expect_fin (data.left, data.left_sent, 10, 7); forward_segment_ltr (&data); + expect_socket_state (data.left, TCP_FIN_WAIT_1); + expect_socket_state (data.right, TCP_CLOSE_WAIT); + + g_assert_cmpint (pseudo_tcp_socket_get_available_bytes (data.left), ==, 0); + g_assert_cmpint (pseudo_tcp_socket_get_available_send_space (data.left), ==, + 0); + expect_ack (data.right, data.right_sent, 7, 11); forward_segment_rtl (&data); + expect_socket_state (data.left, TCP_FIN_WAIT_2); + + + g_assert_cmpint (pseudo_tcp_socket_get_available_bytes (data.right), ==, 3); + + g_assert_cmpint (pseudo_tcp_socket_get_available_send_space (data.right), >, + 0); + /* Check that the data can be read */ g_assert_cmpint (pseudo_tcp_socket_recv (data.right, (char *) buf, sizeof (buf)), ==, 3); |