diff options
| author | yangwei <[email protected]> | 2023-12-07 14:01:21 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2023-12-18 09:48:25 +0800 |
| commit | 8a4f10e8c4082b290c630e378f4b000c8feb7405 (patch) | |
| tree | 734fbba1ffb2bfb68fdaa5eb08c0ab77b3dc588b /include | |
| parent | 558488fbb2ed47c3a50f1a4895dea7616cbfbc5e (diff) | |
✨ feat(max_timeouts_per_msec): 支持设置每个线程主动超时流的速率
Diffstat (limited to 'include')
| -rw-r--r-- | include/private/sapp_global_val.h | 6 | ||||
| -rw-r--r-- | include/private/stream_manage.h | 6 | ||||
| -rw-r--r-- | include/support/token_bucket.h | 6 |
3 files changed, 17 insertions, 1 deletions
diff --git a/include/private/sapp_global_val.h b/include/private/sapp_global_val.h index 3aa1787..911330e 100644 --- a/include/private/sapp_global_val.h +++ b/include/private/sapp_global_val.h @@ -101,10 +101,12 @@ typedef struct{ int meaningful_statistics_minimum_pkt; int meaningful_statistics_minimum_byte; sapp_config_stream_tcp_inject_t inject; - unsigned short *well_known_ports_array; /* ���ڰ�data������ȷ��server�� */ int well_known_ports_array_num; + unsigned short *well_known_ports_array; /* ���ڰ�data������ȷ��server�� */ int closing_timeout; int opening_timeout; + int max_timeouts_per_sec; + int max_opening_per_sec; }sapp_config_stream_tcp_t; @@ -115,6 +117,8 @@ 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 max_timeouts_per_sec; + int max_opening_per_sec; }sapp_config_stream_udp_t; diff --git a/include/private/stream_manage.h b/include/private/stream_manage.h index 1c4a030..cdd91a6 100644 --- a/include/private/stream_manage.h +++ b/include/private/stream_manage.h @@ -4,6 +4,7 @@ #include "stream_internal.h"
#include "stream_register.h"
#include "timeout.h"
+#include "token_bucket.h"
#ifdef __cplusplus
extern "C" {
@@ -91,6 +92,7 @@ struct stream_list long last_update_timer_s;
long interval_to_next_timeout_s;
timeout_error_t timer_error;
+ struct token_bucket *timeout_ratelimiter;
};
struct stream_index_list_item
@@ -118,6 +120,10 @@ struct global_stream long user_define_timer_cnt;
long interval_to_next_timeout_s;
timeout_error_t timer_error;
+ struct token_bucket *tcp_timeout_ratelimiter;
+ struct token_bucket *udp_timeout_ratelimiter;
+ struct token_bucket *udp_opening_ratelimiter;
+ struct token_bucket *tcp_opening_ratelimiter;
};
typedef struct _stStreamFunInfo
diff --git a/include/support/token_bucket.h b/include/support/token_bucket.h new file mode 100644 index 0000000..44e50ee --- /dev/null +++ b/include/support/token_bucket.h @@ -0,0 +1,6 @@ +#pragma once + +struct token_bucket; +struct token_bucket *token_bucket_new(long long now_ms, long long CBS, long long CIR); +void token_bucket_free(struct token_bucket *t); +int token_bucket_consume(struct token_bucket *t, long long tokens, long long now_ms);
\ No newline at end of file |
