optimizate: pass the current timeout to the ID generator as a parameter, instead of getting the time from the ID generator itself
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "id_generator.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_manager.h"
|
||||
#include "tcp_reassembly.h"
|
||||
@@ -307,7 +307,6 @@ TEST(CASE, TCP_FAST_OPEN)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -421,6 +420,11 @@ TEST(CASE, TCP_FAST_OPEN)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct id_generator_options opt = {
|
||||
.snowflake_worker_id_base = 1,
|
||||
.snowflake_worker_id_offset = 2,
|
||||
};
|
||||
id_generator_init(&opt);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "tcp_utils.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
#include "id_generator.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
@@ -92,7 +92,6 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_FIN_FIN)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -185,7 +184,6 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_C2S_RST)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -273,7 +271,6 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_S2C_RST)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -359,7 +356,6 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_DATA_TIMEOUT)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -409,7 +405,6 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_C2S_HALF_CLOSED_TIMEOUT)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -490,7 +485,6 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_S2C_HALF_CLOSED_TIMEOUT)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -560,6 +554,11 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_S2C_HALF_CLOSED_TIMEOUT)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct id_generator_options opt = {
|
||||
.snowflake_worker_id_base = 1,
|
||||
.snowflake_worker_id_offset = 2,
|
||||
};
|
||||
id_generator_init(&opt);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "ip4_utils.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
#include "id_generator.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
@@ -63,7 +63,6 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -142,7 +141,6 @@ TEST(TCP_INIT_TO_OPENING, BY_SYNACK)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -221,7 +219,6 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_SYNACK)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -312,7 +309,6 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_SYNACK_ACK)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -417,7 +413,6 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_RETRANSMISSION)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -515,7 +510,6 @@ TEST(TCP_INIT_TO_OPENING, BY_SYNACK_RETRANSMISSION)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -612,7 +606,6 @@ TEST(TCP_INIT_TO_OPENING, BY_C2S_ASMMETRIC)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -703,7 +696,6 @@ TEST(TCP_INIT_TO_OPENING, BY_S2C_ASMMETRIC)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -783,6 +775,11 @@ TEST(TCP_INIT_TO_OPENING, BY_S2C_ASMMETRIC)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct id_generator_options opt = {
|
||||
.snowflake_worker_id_base = 1,
|
||||
.snowflake_worker_id_offset = 2,
|
||||
};
|
||||
id_generator_init(&opt);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
#include "id_generator.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
@@ -58,7 +58,6 @@ TEST(TCP_INIT_TO_OPENING_TO_ACTIVE_TO_CLOSING_TO_CLOSED, TEST)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -445,6 +444,11 @@ TEST(TCP_INIT_TO_OPENING_TO_ACTIVE_TO_CLOSING_TO_CLOSED, TEST)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct id_generator_options opt = {
|
||||
.snowflake_worker_id_base = 1,
|
||||
.snowflake_worker_id_offset = 2,
|
||||
};
|
||||
id_generator_init(&opt);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
#include "id_generator.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
@@ -62,7 +62,6 @@ TEST(TCP_OPENING_TO_ACTIVE, BY_SYN_C2S_DATA)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -153,7 +152,6 @@ TEST(TCP_OPENING_TO_ACTIVE, BY_SYNACK_S2C_DATA)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -233,6 +231,11 @@ TEST(TCP_OPENING_TO_ACTIVE, BY_SYNACK_S2C_DATA)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct id_generator_options opt = {
|
||||
.snowflake_worker_id_base = 1,
|
||||
.snowflake_worker_id_offset = 2,
|
||||
};
|
||||
id_generator_init(&opt);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "tcp_utils.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
#include "id_generator.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
@@ -63,7 +63,6 @@ TEST(TCP_OPENING_TO_CLOSING, BY_FIN_FIN)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -165,7 +164,6 @@ TEST(TCP_OPENING_TO_CLOSING, BY_C2S_RST)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -262,7 +260,6 @@ TEST(TCP_OPENING_TO_CLOSING, BY_S2C_RST)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -358,7 +355,6 @@ TEST(TCP_OPENING_TO_CLOSING, BY_INIT_TIMEOUT)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -417,7 +413,6 @@ TEST(TCP_OPENING_TO_CLOSING, BY_HANDSHAKE_TIMEOUT)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -508,7 +503,6 @@ TEST(TCP_OPENING_TO_CLOSING, BY_DATA_TIMEOUT)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -611,7 +605,6 @@ TEST(TCP_OPENING_TO_CLOSING, BY_C2S_HALF_FIN)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -701,7 +694,6 @@ TEST(TCP_OPENING_TO_CLOSING, BY_S2C_HALF_FIN)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -780,6 +772,11 @@ TEST(TCP_OPENING_TO_CLOSING, BY_S2C_HALF_FIN)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct id_generator_options opt = {
|
||||
.snowflake_worker_id_base = 1,
|
||||
.snowflake_worker_id_offset = 2,
|
||||
};
|
||||
id_generator_init(&opt);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
#include "id_generator.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
@@ -58,7 +58,6 @@ TEST(UDP_INIT_TO_OPENING_TO_ACTIVE_TO_CLOSING, TEST)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -157,6 +156,11 @@ TEST(UDP_INIT_TO_OPENING_TO_ACTIVE_TO_CLOSING, TEST)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct id_generator_options opt = {
|
||||
.snowflake_worker_id_base = 1,
|
||||
.snowflake_worker_id_offset = 2,
|
||||
};
|
||||
id_generator_init(&opt);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
#include "id_generator.h"
|
||||
#include "session_utils.h"
|
||||
#include "session_manager.h"
|
||||
#include "test_packets.h"
|
||||
@@ -63,7 +63,6 @@ TEST(UDP_INIT_TO_OPENING_TO_CLOSING, BY_C2S)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -143,7 +142,6 @@ TEST(UDP_INIT_TO_OPENING_TO_CLOSING, BY_S2C)
|
||||
struct session_manager *mgr = NULL;
|
||||
struct session_manager_stat *stat = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -213,6 +211,11 @@ TEST(UDP_INIT_TO_OPENING_TO_CLOSING, BY_S2C)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct id_generator_options opt = {
|
||||
.snowflake_worker_id_base = 1,
|
||||
.snowflake_worker_id_offset = 2,
|
||||
};
|
||||
id_generator_init(&opt);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
@@ -55,7 +54,6 @@ TEST(TIMEOUT, TCP_TIMEOUT_DATA)
|
||||
struct session *sess = NULL;
|
||||
struct session_manager *mgr = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
@@ -55,7 +54,6 @@ TEST(TIMEOUT, TCP_TIMEOUT_HANDSHAKE)
|
||||
struct session *sess = NULL;
|
||||
struct session_manager *mgr = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
@@ -55,7 +54,6 @@ TEST(TIMEOUT, TCP_TIMEOUT_INIT)
|
||||
struct session *sess = NULL;
|
||||
struct session_manager *mgr = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "times.h"
|
||||
#include "packet_def.h"
|
||||
#include "packet_parse.h"
|
||||
#include "packet_layer.h"
|
||||
@@ -55,7 +54,6 @@ TEST(TIMEOUT, UDP_TIMEOUT_DATA1)
|
||||
struct session *sess = NULL;
|
||||
struct session_manager *mgr = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
@@ -92,7 +90,6 @@ TEST(TIMEOUT, UDP_TIMEOUT_DATA2)
|
||||
struct session *sess = NULL;
|
||||
struct session_manager *mgr = NULL;
|
||||
|
||||
stellar_update_time_cache();
|
||||
mgr = session_manager_new(&opts, 1);
|
||||
EXPECT_TRUE(mgr != NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user