1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*
�����������ݰ�, CPU����ʱ, �ڰ������̵߳��������е��ô˽ӿ�,
������htable��ʱ��̭,
��ԾIP���ø���(ԭ�������Ե�, �û�������һ������, ����в��Ե���; ��֮, ԭ�������в���, ��ɾ����),
��˺����ӿ��ڰ������̵߳���������, ��ʵ�ְ������߳���������ʱ������, �������!!
*/
#include "flowood.h"
#include "flowood_fun.h"
#include "flwd_net.h"
#include "MESA_handle_logger.h"
#include "MESA_atomic.h"
#include <linux/if_ether.h>
#include <linux/if_arp.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <string.h>
#include <assert.h>
extern MESA_ATOMIC_T flwd_temp_active_ip_op_flag[FLWD_MAX_THREAD_NUM];
/* �ڰ������߳������Ĵ�����ԾIP�ĸ���, ����ģʽ */
static int flwd_act_ip_update_in_process_thread_context(int tid)
{
#if FLWD_ASYNC_LOCK_FREE
int ret;
flwd_active_ip_t tmp_act_ip;
long buf_len;
if(0 == MESA_lqueue_get_count(flwd_temp_active_ip_to_deal[tid])){
/* û���µ����� */
return 0;
}
if(FLWD_ACT_IP_OP_OR_MASK_BY_CALLBACK & __sync_or_and_fetch(&flwd_temp_active_ip_op_flag[tid], FLWD_ACT_IP_OP_OR_MASK_BY_PROC)){
/* callback�̻߳��ڴ�����, �˴����ܵȴ�, ��ձ�־λ��, ֱ�ӷ��ص���һ�ε��� */
__sync_and_and_fetch(&flwd_temp_active_ip_op_flag[tid], FLWD_ACT_IP_OP_AND_MASK_BY_PROC);
return 0;
}
buf_len = sizeof(flwd_active_ip_t);
ret = MESA_lqueue_get_head(flwd_temp_active_ip_to_deal[tid], &tmp_act_ip, &buf_len);
assert(ret >= 0);
flwd_act_ip_hash_proc(tid, &tmp_act_ip);
/* �������, �����־λ */
__sync_and_and_fetch(&flwd_temp_active_ip_op_flag[tid], FLWD_ACT_IP_OP_AND_MASK_BY_PROC);
return 1;
#else
return 0;
#endif
}
int flwd_idle_call(int tid)
{
int ret;
ret = flwd_act_ip_update_in_process_thread_context(tid);
return ret;
}
|