summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author杨威 <[email protected]>2023-06-11 16:49:42 +0800
committer杨威 <[email protected]>2023-06-11 16:49:42 +0800
commit7533e13195cb972fc43a8ed6d43f84892a19da74 (patch)
tree42caa8a061d2da2f372cecb6746d8c96be2f8fe6
parent0cfb3fa0502a7c4bad6e25c9e32f87b1bd59e52f (diff)
✨ feat(tcp timeout): 增加tcp.closing_timeout参数,默认30sv4.3.8
-rw-r--r--bin/etc/sapp.toml2
-rw-r--r--include/private/sapp_declaration.h3
-rw-r--r--include/private/sapp_global_val.h3
-rw-r--r--src/config/config_parse.cpp26
-rw-r--r--src/dealpkt/stream_manage.c32
5 files changed, 26 insertions, 40 deletions
diff --git a/bin/etc/sapp.toml b/bin/etc/sapp.toml
index 520daa8..bde1554 100644
--- a/bin/etc/sapp.toml
+++ b/bin/etc/sapp.toml
@@ -141,7 +141,6 @@
meaningful_statistics_minimum_pkt=3
meaningful_statistics_minimum_byte=5
- special_timeout_ratio=10
[stream.tcp.inject]
link_mss=1460
@@ -159,7 +158,6 @@
timeout=60
meaningful_statistics_minimum_pkt=3
meaningful_statistics_minimum_byte=5
- special_timeout_ratio=20
[PROFILING]
[profiling.pkt_latency]
diff --git a/include/private/sapp_declaration.h b/include/private/sapp_declaration.h
index 794bf72..277db48 100644
--- a/include/private/sapp_declaration.h
+++ b/include/private/sapp_declaration.h
@@ -62,14 +62,13 @@ extern sapp_global_t *sapp_global_val;
#define g_packet_io_thread_num sapp_global_val->config.cpu.worker_threads
#define max_udp_stream_num sapp_global_val->config.stream.udp.max
#define max_tcp_stream_num sapp_global_val->config.stream.tcp.max
-#define special_udp_timeout_ratio sapp_global_val->config.stream.udp.special_timeout_ratio
-#define special_tcp_timeout_ratio sapp_global_val->config.stream.tcp.special_timeout_ratio
#define create_link_mode sapp_global_val->individual_fixed.create_stream_mode
#define g_iMaxRandVal sapp_global_val->config.stream.tcp.inject.rst_signature_seed1
#define g_iRandKey sapp_global_val->config.stream.tcp.inject.rst_signature_seed2
#define tcp_default_unorder sapp_global_val->config.stream.tcp.reorder_pkt_max
#define tcp_creatlink_model sapp_global_val->individual_fixed.create_stream_mode
#define link_default_nopkt_time sapp_global_val->config.stream.tcp.timeout
+#define tcp_closing_timeout sapp_global_val->config.stream.tcp.closing_timeout
#define udp_reset_time sapp_global_val->config.stream.udp.timeout
#define g_topology_mode sapp_global_val->individual_fixed.depolyment_mode_private
#define g_topology_mode_raw sapp_global_val->config.packet_io.depolyment_mode_bin
diff --git a/include/private/sapp_global_val.h b/include/private/sapp_global_val.h
index 111eaad..bee40d3 100644
--- a/include/private/sapp_global_val.h
+++ b/include/private/sapp_global_val.h
@@ -107,7 +107,7 @@ typedef struct{
sapp_config_stream_tcp_inject_t inject;
unsigned short *well_known_ports_array; /* ���ڰ�data������ȷ��server�� */
int well_known_ports_array_num;
- int special_timeout_ratio;
+ int closing_timeout;
}sapp_config_stream_tcp_t;
@@ -118,7 +118,6 @@ typedef struct{
int meaningful_statistics_minimum_byte;
unsigned short *well_known_ports_array; /* �����½�����ȷ��server��, ����4001->8000, ʵ������OICQ��C2S�������ݰ�,֮ǰ�İ汾�ᱻ��ʶ��ΪS2C����� */
int well_known_ports_array_num;
- int special_timeout_ratio;
}sapp_config_stream_udp_t;
diff --git a/src/config/config_parse.cpp b/src/config/config_parse.cpp
index a10ae1d..b0dc4db 100644
--- a/src/config/config_parse.cpp
+++ b/src/config/config_parse.cpp
@@ -1831,18 +1831,8 @@ int sapp_parse_config(void)
/******************************* STREAM.TCP ******************************/
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp", (char *)"max", (int *)&pconfig->stream.tcp.max, 50000);
- tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp", (char *)"special_timeout_ratio", (int *)&pconfig->stream.tcp.special_timeout_ratio, 10);
- if(pconfig->stream.tcp.special_timeout_ratio>100)
- {
- pconfig->stream.tcp.special_timeout_ratio = 100;
- }
- else if(pconfig->stream.tcp.special_timeout_ratio<0)
- {
- pconfig->stream.tcp.special_timeout_ratio = 0;
- }
- else
- ;
- tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp", (char *)"timeout", (int *)&pconfig->stream.tcp.timeout, 60);
+
+ tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp", (char *)"timeout", (int *)&pconfig->stream.tcp.timeout, 180);
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp", (char *)"syn_mandatory", (int *)&pconfig->stream.tcp.syn_mandatory, 1);
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp", (char *)"reorder_pkt_max", (int *)&pconfig->stream.tcp.reorder_pkt_max, 5);
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp", (char *)"analyse_option_enabled", (int *)&pconfig->stream.tcp.analyse_option_enabled, 1);
@@ -1850,6 +1840,7 @@ int sapp_parse_config(void)
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp", (char *)"meaningful_statistics_minimum_pkt", (int *)&pconfig->stream.tcp.meaningful_statistics_minimum_pkt, 3);
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp", (char *)"meaningful_statistics_minimum_byte", (int *)&pconfig->stream.tcp.meaningful_statistics_minimum_byte, 5);
+ tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp", (char *)"closing_timeout", (int *)&pconfig->stream.tcp.closing_timeout, 30);
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp.inject", (char *)"link_mss", (int *)&pconfig->stream.tcp.inject.link_mss, 1460);
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.tcp.inject.rst", (char *)"auto_remedy", (int *)&pconfig->stream.tcp.inject.auto_remedy, 0);
@@ -1862,17 +1853,6 @@ int sapp_parse_config(void)
/******************************* STREAM.UDP ******************************/
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.udp", (char *)"max", (int *)&pconfig->stream.udp.max, 5000);
- tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.udp", (char *)"special_timeout_ratio", (int *)&pconfig->stream.udp.special_timeout_ratio, 20);
- if(pconfig->stream.udp.special_timeout_ratio>100)
- {
- pconfig->stream.udp.special_timeout_ratio = 100;
- }
- else if(pconfig->stream.udp.special_timeout_ratio<0)
- {
- pconfig->stream.udp.special_timeout_ratio = 0;
- }
- else
- ;
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.udp", (char *)"timeout", (int *)&pconfig->stream.udp.timeout, 60);
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.udp", (char *)"meaningful_statistics_minimum_pkt", (int *)&pconfig->stream.udp.meaningful_statistics_minimum_pkt, 3);
tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"stream.udp", (char *)"meaningful_statistics_minimum_byte", (int *)&pconfig->stream.udp.meaningful_statistics_minimum_byte, 5);
diff --git a/src/dealpkt/stream_manage.c b/src/dealpkt/stream_manage.c
index 74a5fc5..3e35794 100644
--- a/src/dealpkt/stream_manage.c
+++ b/src/dealpkt/stream_manage.c
@@ -197,10 +197,6 @@ static void stream_timeout_shift_lrulist(struct streamindex *pindex, unsigned sh
lru_list_root=&(G_MESA_GLOBAL_STREAM[pstream->threadnum]->udpList[pstream->stream_state]);
}
- if(lru_list_root->cnt == 1){ /* ��ǰ��ʣ���һ����, �����ƶ� */
- return;
- }
-
timeouts_add(lru_list_root->streamindex_timer, &pindex->timeout, new_timeout+g_CurrentTime);
return;
@@ -360,10 +356,18 @@ void streamaddlist(struct streamindex *pindex,struct stream_list *plist)
}
struct streaminfo *pstream=(struct streaminfo *)(&(pindex->stream));
- long set_timeout = pindex->stream.timeout;
- if(set_timeout == 0)set_timeout = MAX_DEFALUT_TIMEOUT_S;
+
timeout_init(&pindex->timeout, TIMEOUT_ABS);
- timeouts_add(plist->streamindex_timer, &pindex->timeout, set_timeout+g_CurrentTime);
+ if(pstream->stream_state==TCP_NOUSE_STATE && pstream->type == STREAM_TYPE_TCP)
+ {
+ timeouts_add(plist->streamindex_timer, &pindex->timeout, tcp_closing_timeout+g_CurrentTime);
+ }
+ else
+ {
+ long set_timeout = pindex->stream.timeout;
+ if(set_timeout == 0)set_timeout = MAX_DEFALUT_TIMEOUT_S;
+ timeouts_add(plist->streamindex_timer, &pindex->timeout, set_timeout+g_CurrentTime);
+ }
plist->cnt++;
update_stream_status(pstream->threadnum, pstream->type, pstream->stream_state, 1);
@@ -527,10 +531,16 @@ int lrustream(struct streamindex *pindex)
return 1;
}
}
- long set_timeout = pindex->stream.timeout;
- if(set_timeout == 0)set_timeout = MAX_DEFALUT_TIMEOUT_S;
- timeouts_add(plist->streamindex_timer, &pindex->timeout, g_CurrentTime+set_timeout);
-
+ if(pstream->stream_state==TCP_NOUSE_STATE && pstream->type == STREAM_TYPE_TCP)
+ {
+ timeouts_add(plist->streamindex_timer, &pindex->timeout, tcp_closing_timeout+g_CurrentTime);
+ }
+ else
+ {
+ long set_timeout = pindex->stream.timeout;
+ if(set_timeout == 0)set_timeout = MAX_DEFALUT_TIMEOUT_S;
+ timeouts_add(plist->streamindex_timer, &pindex->timeout, set_timeout+g_CurrentTime);
+ }
return 0;
}