diff options
| author | lijia <[email protected]> | 2021-03-05 15:54:48 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2021-03-05 15:54:48 +0800 |
| commit | b3aaf1bf758ef5d39cf14f1d82220dd922e454cc (patch) | |
| tree | 514371dae2ec24dad1fdf28e8e80e3d5a53cb797 | |
| parent | 939e465cc81692ac3468fce23aae51898ec97ff7 (diff) | |
增加在polling接口中增加超时淘汰功能:v4.2.27
1)实现无数据包时的精确超时淘汰功能;
2)无数据包到达时,CPU实际上是空闲的,在此刻将之前的旧流结束,而不是在新数据包到达时再淘汰旧流,可以提升一些处理性能,降低新数据包的处理延时.
| -rw-r--r-- | include/private/stream_manage.h | 1 | ||||
| -rw-r--r-- | src/dealpkt/stream_manage.c | 36 | ||||
| -rw-r--r-- | src/packet_io/packet_io_marsio.c | 3 | ||||
| -rw-r--r-- | src/packet_io/packet_io_pcap.c | 4 |
4 files changed, 44 insertions, 0 deletions
diff --git a/include/private/stream_manage.h b/include/private/stream_manage.h index 53432d4..06aa294 100644 --- a/include/private/stream_manage.h +++ b/include/private/stream_manage.h @@ -164,6 +164,7 @@ void udp_free_stream(struct streamindex *pstream); int tcp_free_stream(struct streamindex *pstream, const void*, const void *,const raw_pkt_t *raw_pkt);
void update_opposite_addr_info(struct streaminfo_private *pstream_pr,
struct streaminfo_private *p_stack, unsigned char cur_dir);
+int polling_stream_timeout(int tid);
#ifdef __cplusplus
}
diff --git a/src/dealpkt/stream_manage.c b/src/dealpkt/stream_manage.c index 2fe13d6..3d7549d 100644 --- a/src/dealpkt/stream_manage.c +++ b/src/dealpkt/stream_manage.c @@ -3014,6 +3014,42 @@ int sapp_is_overlay_layer(const struct streaminfo_private *stream_pr, const raw_ return 0; } + +/* + �ײ����������ݰ�ʱ, ������Щ��̭����, ����Ŀ��: + 1) ʵ���ް���ʱ��̭����, ����ȷ; + 2) �����ݰ�ʱ��ǰ��֮ǰ�ľ�������, �����ǿ������ݰ�����ʱ����̭����, ��������һЩ�������ܺͽ��Ͱ�������ʱ. +*/ +int polling_stream_timeout(int tid) +{ + struct stream_list *plist=NULL; + int i, ret, has_work = 0; + + for(i = UDP_ONE_STATE; i < MAX_UDP_STATE; i++){ + plist=&(G_MESA_GLOBAL_STREAM[tid]->udpList[i]); + if(plist->head){ /* polling�ο��ܻ�û����, ����û�д�״̬����, plist����ΪNULL */ + ret = del_stream_by_time(plist, NULL); + if(ret > 0){ + has_work = POLLING_STATE_WORK; + } + } + } + + for(i = TCP_SYN_STATE; i < MAX_TCP_STATE; i++){ + plist=&(G_MESA_GLOBAL_STREAM[tid]->tcpList[i]); + if(plist->head){ /* polling�ο��ܻ�û����, ����û�д�״̬����, plist����ΪNULL */ + ret = del_stream_by_time(plist, NULL); + if(ret > 0){ + has_work = POLLING_STATE_WORK; + } + } + } + + return has_work; +} + + + #ifdef __cplusplus } #endif diff --git a/src/packet_io/packet_io_marsio.c b/src/packet_io/packet_io_marsio.c index d542e59..6e63d35 100644 --- a/src/packet_io/packet_io_marsio.c +++ b/src/packet_io/packet_io_marsio.c @@ -840,6 +840,9 @@ static void *marsio4_worker(void *arg) if((stream_process_polling(tid) & POLLING_STATE_WORK) != 0){ polling_work_times++; } + if(polling_stream_timeout(tid) & POLLING_STATE_WORK){ + polling_work_times++; + } } total_call_times++; diff --git a/src/packet_io/packet_io_pcap.c b/src/packet_io/packet_io_pcap.c index bf4b842..9547237 100644 --- a/src/packet_io/packet_io_pcap.c +++ b/src/packet_io/packet_io_pcap.c @@ -764,6 +764,9 @@ static void *__pcap_work_thread(void *arg) if(stream_process_polling(thread_num) != 0){
polling_work_times++;
}
+ if(polling_stream_timeout(thread_num) != 0){
+ polling_work_times++;
+ }
total_call_times++;
if(total_call_times >= 100){
@@ -798,6 +801,7 @@ static void *__pcap_work_thread(void *arg) if(PCAP_OP_FLAG_IDLE_POLLING == pkt_queue_node.op_flag){
idle_polling_call(thread_num);
+ polling_stream_timeout(thread_num);
continue;
}else if(PCAP_OP_FLAG_EOF == pkt_queue_node.op_flag){
packet_io_clean_thread_context(thread_num);
|
