Update session timer
This commit is contained in:
@@ -238,8 +238,8 @@ TEST(SESS_MGR_TCP_REASSEMBLY, OUT_OF_ORDER)
|
||||
session_consume_tcp_payload(sess, len);
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 7 + opts.tcp_data_timeout) == NULL); // active -> closing
|
||||
sess = session_manager_get_expired_session(mgr, 7 + opts.tcp_data_timeout + opts.tcp_time_wait_timeout); // closing -> closed
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 7 + opts.tcp_data_timeout) == NULL); // active -> closing
|
||||
sess = session_manager_get_expired_session(mgr, 7 + opts.tcp_data_timeout + opts.tcp_data_timeout); // closing -> closed
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -330,8 +330,8 @@ TEST(SESS_MGR_TCP_REASSEMBLY, SEQ_WRAPAROUND)
|
||||
session_consume_tcp_payload(sess, len);
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 4 + opts.tcp_data_timeout) == NULL); // active -> closing
|
||||
sess = session_manager_get_expired_session(mgr, 4 + opts.tcp_data_timeout + opts.tcp_time_wait_timeout); // closing -> closed
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 4 + opts.tcp_data_timeout) == NULL); // active -> closing
|
||||
sess = session_manager_get_expired_session(mgr, 4 + opts.tcp_data_timeout + opts.tcp_data_timeout); // closing -> closed
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
|
||||
@@ -3,62 +3,42 @@
|
||||
#include "session_timer.h"
|
||||
#include "session_private.h"
|
||||
|
||||
static void session_expire(struct session *sess, void *arg)
|
||||
{
|
||||
printf("=== session %lu expired ===\n", session_get_id(sess));
|
||||
}
|
||||
|
||||
TEST(SESSION_TIMER, ADD_DEL)
|
||||
{
|
||||
struct session sess;
|
||||
struct session_timer *timer = session_timer_new();
|
||||
EXPECT_TRUE(timer != NULL);
|
||||
|
||||
session_init(&sess);
|
||||
session_set_id(&sess, 1);
|
||||
session_set_expirecb(&sess, session_expire, NULL, 1000);
|
||||
|
||||
session_timer_add(timer, &sess);
|
||||
session_timer_del(timer, &sess);
|
||||
|
||||
session_timer_free(timer);
|
||||
}
|
||||
|
||||
TEST(SESSION_TIMER, EXPIRE)
|
||||
{
|
||||
struct session *sess = NULL;
|
||||
struct session sess1;
|
||||
struct session sess2;
|
||||
struct session sess3;
|
||||
struct session_timer *timer = session_timer_new();
|
||||
struct session_timer *timer = session_timer_new(100);
|
||||
EXPECT_TRUE(timer != NULL);
|
||||
|
||||
session_init(&sess1);
|
||||
session_init(&sess2);
|
||||
session_init(&sess3);
|
||||
session_set_id(&sess1, 1);
|
||||
session_set_id(&sess2, 2);
|
||||
session_set_id(&sess3, 3);
|
||||
session_set_expirecb(&sess1, session_expire, NULL, 5);
|
||||
session_set_expirecb(&sess2, session_expire, NULL, 5);
|
||||
session_set_expirecb(&sess3, session_expire, NULL, 10);
|
||||
|
||||
session_timer_add(timer, &sess1);
|
||||
session_timer_add(timer, &sess2);
|
||||
session_timer_add(timer, &sess3);
|
||||
session_timer_add(timer, &sess1, 100 + 5);
|
||||
session_timer_add(timer, &sess2, 100 + 5);
|
||||
session_timer_add(timer, &sess3, 100 + 10);
|
||||
|
||||
for (uint64_t abs_current_ts = 0; abs_current_ts < 15; abs_current_ts++)
|
||||
{
|
||||
printf("current timestamp %lu\n", abs_current_ts);
|
||||
do
|
||||
{
|
||||
sess = session_timer_expire(timer, abs_current_ts);
|
||||
if (sess != NULL)
|
||||
{
|
||||
session_run_expirecb(sess);
|
||||
}
|
||||
} while (sess);
|
||||
}
|
||||
// not expire
|
||||
sess = session_timer_expire(timer, 100 + 4);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
// expire
|
||||
sess = session_timer_expire(timer, 100 + 5);
|
||||
EXPECT_TRUE(sess == &sess1);
|
||||
sess = session_timer_expire(timer, 100 + 5);
|
||||
EXPECT_TRUE(sess == &sess2);
|
||||
// not expire
|
||||
sess = session_timer_expire(timer, 100 + 5);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
sess = session_timer_expire(timer, 100 + 9);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
// expire
|
||||
sess = session_timer_expire(timer, 100 + 10);
|
||||
EXPECT_TRUE(sess == &sess3);
|
||||
// not expire
|
||||
sess = session_timer_expire(timer, 100 + 10);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
|
||||
session_timer_free(timer);
|
||||
}
|
||||
@@ -69,40 +49,65 @@ TEST(SESSION_TIMER, BEFORE_EXPIRE_DEL)
|
||||
struct session sess1;
|
||||
struct session sess2;
|
||||
struct session sess3;
|
||||
struct session_timer *timer = session_timer_new();
|
||||
struct session_timer *timer = session_timer_new(1);
|
||||
EXPECT_TRUE(timer != NULL);
|
||||
|
||||
session_init(&sess1);
|
||||
session_init(&sess2);
|
||||
session_init(&sess3);
|
||||
session_set_id(&sess1, 1);
|
||||
session_set_id(&sess2, 2);
|
||||
session_set_id(&sess3, 3);
|
||||
session_set_expirecb(&sess1, session_expire, NULL, 5);
|
||||
session_set_expirecb(&sess2, session_expire, NULL, 5);
|
||||
session_set_expirecb(&sess3, session_expire, NULL, 10);
|
||||
|
||||
session_timer_add(timer, &sess1);
|
||||
session_timer_add(timer, &sess2);
|
||||
session_timer_add(timer, &sess3);
|
||||
session_timer_add(timer, &sess1, 100 + 5);
|
||||
session_timer_add(timer, &sess2, 100 + 5);
|
||||
session_timer_add(timer, &sess3, 100 + 10);
|
||||
|
||||
for (uint64_t abs_current_ts = 0; abs_current_ts < 15; abs_current_ts++)
|
||||
{
|
||||
printf("current timestamp %lu\n", abs_current_ts);
|
||||
if (abs_current_ts == 2)
|
||||
{
|
||||
printf("delete timer 2\n");
|
||||
session_timer_del(timer, &sess2);
|
||||
}
|
||||
do
|
||||
{
|
||||
sess = session_timer_expire(timer, abs_current_ts);
|
||||
if (sess != NULL)
|
||||
{
|
||||
session_run_expirecb(sess);
|
||||
}
|
||||
} while (sess);
|
||||
}
|
||||
// not expire
|
||||
sess = session_timer_expire(timer, 100 + 4);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
// del sess1
|
||||
session_timer_del(timer, &sess1);
|
||||
// expire
|
||||
sess = session_timer_expire(timer, 100 + 5);
|
||||
EXPECT_TRUE(sess == &sess2);
|
||||
sess = session_timer_expire(timer, 100 + 5);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
// expire
|
||||
sess = session_timer_expire(timer, 100 + 10);
|
||||
EXPECT_TRUE(sess == &sess3);
|
||||
// not expire
|
||||
sess = session_timer_expire(timer, 100 + 10);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
|
||||
session_timer_free(timer);
|
||||
}
|
||||
|
||||
TEST(SESSION_TIMER, AFTER_EXPIRE_DEL)
|
||||
{
|
||||
struct session *sess = NULL;
|
||||
struct session sess1;
|
||||
struct session sess2;
|
||||
struct session sess3;
|
||||
struct session_timer *timer = session_timer_new(1);
|
||||
EXPECT_TRUE(timer != NULL);
|
||||
|
||||
session_init(&sess1);
|
||||
session_init(&sess2);
|
||||
session_init(&sess3);
|
||||
|
||||
session_timer_add(timer, &sess1, 100 + 5);
|
||||
session_timer_add(timer, &sess2, 100 + 5);
|
||||
session_timer_add(timer, &sess3, 100 + 10);
|
||||
|
||||
// expire
|
||||
sess = session_timer_expire(timer, 100 + 5);
|
||||
EXPECT_TRUE(sess == &sess1);
|
||||
// del sess2
|
||||
session_timer_del(timer, &sess2);
|
||||
// not expire
|
||||
sess = session_timer_expire(timer, 100 + 5);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
// expire
|
||||
sess = session_timer_expire(timer, 100 + 10);
|
||||
EXPECT_TRUE(sess == &sess3);
|
||||
|
||||
session_timer_free(timer);
|
||||
}
|
||||
@@ -112,43 +117,32 @@ TEST(SESSION_TIMER, BEFORE_EXPIRE_UPDATE)
|
||||
struct session *sess = NULL;
|
||||
struct session sess1;
|
||||
struct session sess2;
|
||||
struct session sess3;
|
||||
struct session_timer *timer = session_timer_new();
|
||||
struct session_timer *timer = session_timer_new(100);
|
||||
EXPECT_TRUE(timer != NULL);
|
||||
|
||||
session_init(&sess1);
|
||||
session_init(&sess2);
|
||||
session_init(&sess3);
|
||||
session_set_id(&sess1, 1);
|
||||
session_set_id(&sess2, 2);
|
||||
session_set_id(&sess3, 3);
|
||||
session_set_expirecb(&sess1, session_expire, NULL, 5);
|
||||
session_set_expirecb(&sess2, session_expire, NULL, 5);
|
||||
session_set_expirecb(&sess3, session_expire, NULL, 10);
|
||||
|
||||
session_timer_add(timer, &sess1);
|
||||
session_timer_add(timer, &sess2);
|
||||
session_timer_add(timer, &sess3);
|
||||
session_timer_add(timer, &sess1, 100 + 5);
|
||||
session_timer_add(timer, &sess2, 100 + 10);
|
||||
|
||||
for (uint64_t abs_current_ts = 0; abs_current_ts < 15; abs_current_ts++)
|
||||
{
|
||||
printf("current timestamp %lu\n", abs_current_ts);
|
||||
if (abs_current_ts == 2)
|
||||
{
|
||||
printf("update timer 2\n");
|
||||
session_timer_del(timer, &sess2);
|
||||
session_set_expirecb(&sess2, session_expire, NULL, 8);
|
||||
session_timer_add(timer, &sess2);
|
||||
}
|
||||
do
|
||||
{
|
||||
sess = session_timer_expire(timer, abs_current_ts);
|
||||
if (sess != NULL)
|
||||
{
|
||||
session_run_expirecb(sess);
|
||||
}
|
||||
} while (sess);
|
||||
}
|
||||
// not expire
|
||||
sess = session_timer_expire(timer, 100 + 4);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
// expire
|
||||
sess = session_timer_expire(timer, 100 + 5);
|
||||
EXPECT_TRUE(sess == &sess1);
|
||||
// not expire
|
||||
sess = session_timer_expire(timer, 100 + 5);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
// update sess2
|
||||
session_timer_update(timer, &sess2, 100 + 20);
|
||||
// not expire
|
||||
sess = session_timer_expire(timer, 100 + 19);
|
||||
EXPECT_TRUE(sess == NULL);
|
||||
// expire
|
||||
sess = session_timer_expire(timer, 100 + 20);
|
||||
EXPECT_TRUE(sess == &sess2);
|
||||
|
||||
session_timer_free(timer);
|
||||
}
|
||||
@@ -157,20 +151,16 @@ TEST(SESSION_TIMER, NEXT_EXPIRE_INTERVAL)
|
||||
{
|
||||
struct session sess1;
|
||||
struct session sess2;
|
||||
struct session_timer *timer = session_timer_new();
|
||||
struct session_timer *timer = session_timer_new(100);
|
||||
EXPECT_TRUE(timer != NULL);
|
||||
|
||||
session_init(&sess1);
|
||||
session_init(&sess2);
|
||||
session_set_id(&sess1, 1);
|
||||
session_set_id(&sess2, 2);
|
||||
session_set_expirecb(&sess1, session_expire, NULL, 1000);
|
||||
session_set_expirecb(&sess2, session_expire, NULL, 1000);
|
||||
|
||||
EXPECT_TRUE(session_timer_next_expire_interval(timer) == UINT64_MAX);
|
||||
|
||||
session_timer_add(timer, &sess1);
|
||||
session_timer_add(timer, &sess2);
|
||||
session_timer_add(timer, &sess1, 1000);
|
||||
session_timer_add(timer, &sess2, 1000);
|
||||
EXPECT_TRUE(session_timer_next_expire_interval(timer) < UINT64_MAX);
|
||||
|
||||
EXPECT_TRUE(session_timer_expire(timer, 900) == NULL);
|
||||
|
||||
@@ -370,7 +370,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_DATA_TIMEOUT)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -451,7 +451,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_C2S_HALF_CLOSED_TIMEOUT)
|
||||
EXPECT_TRUE(stat->tcp_sess.nr_sess_closing == 1);
|
||||
|
||||
// expire session
|
||||
sess = session_manager_get_expired_session(mgr, 3 + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 3 + opts.tcp_half_closed_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_CLIENT_FIN);
|
||||
@@ -532,7 +532,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_S2C_HALF_CLOSED_TIMEOUT)
|
||||
EXPECT_TRUE(stat->tcp_sess.nr_sess_closing == 1);
|
||||
|
||||
// expire session
|
||||
sess = session_manager_get_expired_session(mgr, 3 + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 3 + opts.tcp_half_closed_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_SERVER_FIN);
|
||||
|
||||
@@ -105,8 +105,8 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN)
|
||||
EXPECT_TRUE(stat->tcp_sess.nr_sess_closing == 0);
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout) == NULL); // opening -> closing
|
||||
sess = session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout + opts.tcp_time_wait_timeout); // closing -> closed
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout) == NULL); // opening -> closing
|
||||
sess = session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout + opts.tcp_data_timeout); // closing -> closed
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -186,7 +186,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYNACK)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 1 + opts.tcp_handshake_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 1 + opts.tcp_handshake_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 1 + opts.tcp_handshake_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -277,7 +277,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_SYNACK)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 2 + opts.tcp_handshake_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_handshake_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_handshake_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -378,7 +378,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_SYNACK_ACK)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 3 + opts.tcp_data_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 3 + opts.tcp_data_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 3 + opts.tcp_data_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -476,7 +476,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_RETRANSMISSION)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 2 + opts.tcp_init_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_init_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_init_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -575,7 +575,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYNACK_RETRANSMISSION)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 2 + opts.tcp_handshake_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_handshake_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_handshake_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -666,7 +666,7 @@ TEST(TCP_INIT_TO_OPENING, BY_C2S_ASMMETRIC)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -757,7 +757,7 @@ TEST(TCP_INIT_TO_OPENING, BY_S2C_ASMMETRIC)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
|
||||
@@ -115,7 +115,7 @@ TEST(TCP_OPENING_TO_ACTIVE, BY_SYN_C2S_DATA)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -205,7 +205,7 @@ TEST(TCP_OPENING_TO_ACTIVE, BY_SYNACK_S2C_DATA)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
|
||||
@@ -376,7 +376,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_INIT_TIMEOUT)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -466,7 +466,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_HANDSHAKE_TIMEOUT)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 2 + opts.tcp_handshake_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_handshake_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_handshake_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -567,7 +567,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_DATA_TIMEOUT)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 3 + opts.tcp_data_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 3 + opts.tcp_data_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 3 + opts.tcp_data_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
@@ -656,7 +656,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_C2S_HALF_FIN)
|
||||
EXPECT_TRUE(stat->tcp_sess.nr_sess_closing == 1);
|
||||
|
||||
// expire session
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_half_closed_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_CLIENT_FIN);
|
||||
@@ -745,7 +745,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_S2C_HALF_FIN)
|
||||
EXPECT_TRUE(stat->tcp_sess.nr_sess_closing == 1);
|
||||
|
||||
// expire session
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_half_closed_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_SERVER_FIN);
|
||||
|
||||
@@ -79,7 +79,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_DATA)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 2 + opts.tcp_data_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
|
||||
@@ -69,7 +69,7 @@ TEST(TIMEOUT, TCP_TIMEOUT_HANDSHAKE)
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 1 + opts.tcp_handshake_timeout) == NULL);
|
||||
sess = session_manager_get_expired_session(mgr, 1 + opts.tcp_handshake_timeout + opts.tcp_time_wait_timeout);
|
||||
sess = session_manager_get_expired_session(mgr, 1 + opts.tcp_handshake_timeout + opts.tcp_data_timeout);
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
|
||||
@@ -68,8 +68,8 @@ TEST(TIMEOUT, TCP_TIMEOUT_INIT)
|
||||
EXPECT_TRUE(sess);
|
||||
|
||||
// expire session
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout) == NULL); // opening -> closing
|
||||
sess = session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout + opts.tcp_time_wait_timeout); // closing -> closed
|
||||
EXPECT_TRUE(session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout) == NULL); // opening -> closing
|
||||
sess = session_manager_get_expired_session(mgr, 1 + opts.tcp_init_timeout + opts.tcp_data_timeout); // closing -> closed
|
||||
EXPECT_TRUE(sess);
|
||||
EXPECT_TRUE(session_get_state(sess) == SESSION_STATE_CLOSED);
|
||||
EXPECT_TRUE(session_get_closing_reason(sess) == CLOSING_BY_TIMEOUT);
|
||||
|
||||
Reference in New Issue
Block a user