Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Achou.Wang
accel-ppp
提交
369689ab
A
accel-ppp
项目概览
Achou.Wang
/
accel-ppp
通知
6
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
accel-ppp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
369689ab
编写于
11月 29, 2010
作者:
K
Kozlov Dmitry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use atomic operation on statistics update operations
上级
43803998
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
46 addition
and
42 deletion
+46
-42
accel-pptpd/ctrl/l2tp/l2tp.c
accel-pptpd/ctrl/l2tp/l2tp.c
+8
-8
accel-pptpd/ctrl/pppoe/pppoe.c
accel-pptpd/ctrl/pppoe/pppoe.c
+5
-5
accel-pptpd/ctrl/pptp/pptp.c
accel-pptpd/ctrl/pptp/pptp.c
+8
-8
accel-pptpd/log.c
accel-pptpd/log.c
+1
-1
accel-pptpd/triton/md.c
accel-pptpd/triton/md.c
+1
-0
accel-pptpd/triton/mempool.c
accel-pptpd/triton/mempool.c
+9
-9
accel-pptpd/triton/timer.c
accel-pptpd/triton/timer.c
+1
-0
accel-pptpd/triton/triton.c
accel-pptpd/triton/triton.c
+13
-11
未找到文件。
accel-pptpd/ctrl/l2tp/l2tp.c
浏览文件 @
369689ab
...
...
@@ -119,11 +119,11 @@ static void l2tp_disconnect(struct l2tp_conn_t *conn)
triton_timer_del
(
&
conn
->
hello_timer
);
if
(
conn
->
state
==
STATE_PPP
)
{
stat_active
--
;
__sync_sub_and_fetch
(
&
stat_active
,
1
)
;
conn
->
state
=
STATE_FIN
;
ppp_terminate
(
&
conn
->
ppp
,
TERM_USER_REQUEST
,
1
);
}
else
if
(
conn
->
state
!=
STATE_FIN
)
stat_starting
--
;
__sync_sub_and_fetch
(
&
stat_starting
,
1
)
;
pthread_mutex_lock
(
&
l2tp_lock
);
l2tp_conn
[
conn
->
tid
]
=
NULL
;
...
...
@@ -201,7 +201,7 @@ static void l2tp_ppp_finished(struct ppp_t *ppp)
log_ppp_debug
(
"l2tp: ppp finished
\n
"
);
if
(
conn
->
state
!=
STATE_FIN
)
{
stat_active
--
;
__sync_sub_and_fetch
(
&
stat_active
,
1
)
;
if
(
l2tp_terminate
(
conn
,
0
,
0
))
triton_context_call
(
&
conn
->
ctx
,
(
triton_event_func
)
l2tp_disconnect
,
conn
);
}
...
...
@@ -212,7 +212,7 @@ static void l2tp_conn_close(struct triton_context_t *ctx)
struct
l2tp_conn_t
*
conn
=
container_of
(
ctx
,
typeof
(
*
conn
),
ctx
);
if
(
conn
->
state
==
STATE_PPP
)
{
stat_active
--
;
__sync_sub_and_fetch
(
&
stat_active
,
1
)
;
conn
->
state
=
STATE_FIN
;
ppp_terminate
(
&
conn
->
ppp
,
TERM_ADMIN_RESET
,
1
);
}
...
...
@@ -357,7 +357,7 @@ static int l2tp_tunnel_alloc(struct l2tp_serv_t *serv, struct l2tp_packet_t *pac
triton_context_call
(
&
conn
->
ctx
,
(
triton_event_func
)
l2tp_send_SCCRP
,
conn
);
stat_starting
++
;
__sync_add_and_fetch
(
&
stat_starting
,
1
)
;
return
0
;
...
...
@@ -419,8 +419,8 @@ static int l2tp_connect(struct l2tp_conn_t *conn)
if
(
establish_ppp
(
&
conn
->
ppp
))
return
-
1
;
stat_starting
--
;
stat_active
++
;
__sync_sub_and_fetch
(
&
stat_starting
,
1
)
;
__sync_add_and_fetch
(
&
stat_active
,
1
)
;
conn
->
state
=
STATE_PPP
;
...
...
@@ -835,7 +835,7 @@ static int l2tp_recv_CDN(struct l2tp_conn_t *conn, struct l2tp_packet_t *pack)
}
if
(
conn
->
state
==
STATE_PPP
)
{
stat_active
--
;
__sync_sub_and_fetch
(
&
stat_active
,
1
)
;
conn
->
state
=
STATE_FIN
;
ppp_terminate
(
&
conn
->
ppp
,
TERM_USER_REQUEST
,
1
);
}
...
...
accel-pptpd/ctrl/pppoe/pppoe.c
浏览文件 @
369689ab
...
...
@@ -82,7 +82,7 @@ void pppoe_server_free(struct pppoe_serv_t *serv);
static
void
disconnect
(
struct
pppoe_conn_t
*
conn
)
{
if
(
conn
->
ppp_started
)
{
stat_active
--
;
__sync_sub_and_fetch
(
&
stat_active
,
1
)
;
conn
->
ppp_started
=
0
;
ppp_terminate
(
&
conn
->
ppp
,
TERM_USER_REQUEST
,
1
);
}
...
...
@@ -132,7 +132,7 @@ static void ppp_finished(struct ppp_t *ppp)
log_ppp_debug
(
"pppoe: ppp finished
\n
"
);
if
(
conn
->
ppp_started
)
{
stat_active
--
;
__sync_sub_and_fetch
(
&
stat_active
,
1
)
;
conn
->
ppp_started
=
0
;
triton_context_call
(
&
conn
->
ctx
,
(
triton_event_func
)
disconnect
,
conn
);
}
...
...
@@ -546,7 +546,7 @@ static void free_delayed_pado(struct delayed_pado_t *pado)
{
triton_timer_del
(
&
pado
->
timer
);
stat_delayed_pado
--
;
__sync_sub_and_fetch
(
&
stat_delayed_pado
,
1
)
;
list_del
(
&
pado
->
entry
);
if
(
pado
->
host_uniq
)
...
...
@@ -655,7 +655,7 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size)
triton_timer_add
(
&
serv
->
ctx
,
&
pado
->
timer
,
0
);
list_add_tail
(
&
pado
->
entry
,
&
serv
->
pado_list
);
stat_delayed_pado
++
;
__sync_add_and_fetch
(
&
stat_delayed_pado
,
1
)
;
}
else
pppoe_send_PADO
(
serv
,
ethhdr
->
h_source
,
host_uniq_tag
,
relay_sid_tag
,
service_name_tag
);
}
...
...
@@ -756,7 +756,7 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
if
(
connect_channel
(
conn
))
disconnect
(
conn
);
else
{
stat_active
++
;
__sync_add_and_fetch
(
&
stat_active
,
1
)
;
conn
->
ppp_started
=
1
;
}
}
...
...
accel-pptpd/ctrl/pptp/pptp.c
浏览文件 @
369689ab
...
...
@@ -82,11 +82,11 @@ static void disconnect(struct pptp_conn_t *conn)
triton_timer_del
(
&
conn
->
echo_timer
);
if
(
conn
->
state
==
STATE_PPP
)
{
stat_active
--
;
__sync_sub_and_fetch
(
&
stat_active
,
1
)
;
conn
->
state
=
STATE_CLOSE
;
ppp_terminate
(
&
conn
->
ppp
,
TERM_USER_REQUEST
,
1
);
}
else
if
(
conn
->
state
!=
STATE_CLOSE
)
stat_starting
--
;
__sync_sub_and_fetch
(
&
stat_starting
,
1
)
;
triton_event_fire
(
EV_CTRL_FINISHED
,
&
conn
->
ppp
);
...
...
@@ -329,8 +329,8 @@ static int pptp_out_call_rqst(struct pptp_conn_t *conn)
return
-
1
;
}
conn
->
state
=
STATE_PPP
;
stat_starting
--
;
stat_active
++
;
__sync_sub_and_fetch
(
&
stat_starting
,
1
)
;
__sync_add_and_fetch
(
&
stat_active
,
1
)
;
if
(
conn
->
timeout_timer
.
tpd
)
triton_timer_del
(
&
conn
->
timeout_timer
);
...
...
@@ -367,7 +367,7 @@ static int pptp_call_clear_rqst(struct pptp_conn_t *conn)
log_ppp_info
(
"recv [PPTP Call-Clear-Request <Call-ID %x>]
\n
"
,
ntohs
(
rqst
->
call_id
));
if
(
conn
->
state
==
STATE_PPP
)
{
stat_active
--
;
__sync_sub_and_fetch
(
&
stat_active
,
1
)
;
conn
->
state
=
STATE_CLOSE
;
ppp_terminate
(
&
conn
->
ppp
,
TERM_USER_REQUEST
,
1
);
}
...
...
@@ -549,7 +549,7 @@ static void pptp_close(struct triton_context_t *ctx)
{
struct
pptp_conn_t
*
conn
=
container_of
(
ctx
,
typeof
(
*
conn
),
ctx
);
if
(
conn
->
state
==
STATE_PPP
)
{
stat_active
--
;
__sync_sub_and_fetch
(
&
stat_active
,
1
)
;
conn
->
state
=
STATE_CLOSE
;
ppp_terminate
(
&
conn
->
ppp
,
TERM_ADMIN_RESET
,
1
);
if
(
send_pptp_call_disconnect_notify
(
conn
,
3
))
{
...
...
@@ -579,7 +579,7 @@ static void ppp_finished(struct ppp_t *ppp)
if
(
conn
->
state
!=
STATE_CLOSE
)
{
log_ppp_debug
(
"pptp: ppp finished
\n
"
);
conn
->
state
=
STATE_CLOSE
;
stat_active
--
;
__sync_sub_and_fetch
(
&
stat_active
,
1
)
;
if
(
send_pptp_call_disconnect_notify
(
conn
,
3
))
triton_context_call
(
&
conn
->
ctx
,
(
void
(
*
)(
void
*
))
disconnect
,
conn
);
...
...
@@ -667,7 +667,7 @@ static int pptp_connect(struct triton_md_handler_t *h)
triton_event_fire
(
EV_CTRL_STARTING
,
&
conn
->
ppp
);
stat_starting
++
;
__sync_add_and_fetch
(
&
stat_starting
,
1
)
;
}
return
0
;
}
...
...
accel-pptpd/log.c
浏览文件 @
369689ab
...
...
@@ -260,7 +260,7 @@ static struct log_msg_t *clone_msg(struct _log_msg_t *msg)
m
->
timestamp
=
msg
->
timestamp
;
m
->
level
=
msg
->
level
;
msg
->
refs
++
;
__sync_add_and_fetch
(
&
msg
->
refs
,
1
)
;
//printf("clone msg %p\n", m);
return
m
;
...
...
accel-pptpd/triton/md.c
浏览文件 @
369689ab
...
...
@@ -86,6 +86,7 @@ static void *md_thread(void *arg)
if
(
!
h
->
pending
)
{
list_add_tail
(
&
h
->
entry2
,
&
h
->
ctx
->
pending_handlers
);
h
->
pending
=
1
;
__sync_add_and_fetch
(
&
triton_stat
.
md_handler_pending
,
1
);
r
=
triton_queue_ctx
(
h
->
ctx
);
}
else
r
=
0
;
...
...
accel-pptpd/triton/mempool.c
浏览文件 @
369689ab
...
...
@@ -84,7 +84,7 @@ void __export *mempool_alloc(mempool_t *pool)
list_del
(
&
it
->
entry
);
spin_unlock
(
&
p
->
lock
);
triton_stat
.
mempool_available
-=
size
;
__sync_sub_and_fetch
(
&
triton_stat
.
mempool_available
,
size
)
;
it
->
magic1
=
MAGIC1
;
...
...
@@ -106,7 +106,7 @@ void __export *mempool_alloc(mempool_t *pool)
it
->
magic2
=
p
->
magic
;
*
(
uint64_t
*
)(
it
->
data
+
p
->
size
)
=
it
->
magic2
;
triton_stat
.
mempool_allocated
+=
size
;
__sync_add_and_fetch
(
&
triton_stat
.
mempool_allocated
,
size
)
;
return
it
->
ptr
;
}
...
...
@@ -128,7 +128,7 @@ void __export *mempool_alloc_md(mempool_t *pool, const char *fname, int line)
it
->
fname
=
fname
;
it
->
line
=
line
;
triton_stat
.
mempool_available
-=
size
;
__sync_sub_and_fetch
(
&
triton_stat
.
mempool_available
,
size
)
;
it
->
magic1
=
MAGIC1
;
...
...
@@ -156,7 +156,7 @@ void __export *mempool_alloc_md(mempool_t *pool, const char *fname, int line)
list_add
(
&
it
->
entry
,
&
p
->
ditems
);
spin_unlock
(
&
p
->
lock
);
triton_stat
.
mempool_allocated
+=
size
;
__sync_add_and_fetch
(
&
triton_stat
.
mempool_allocated
,
size
)
;
return
it
->
ptr
;
}
...
...
@@ -202,7 +202,7 @@ void __export mempool_free(void *ptr)
_free
(
it
);
#endif
triton_stat
.
mempool_available
+=
size
;
__sync_add_and_fetch
(
&
triton_stat
.
mempool_available
,
size
)
;
}
void
__export
mempool_clean
(
mempool_t
*
pool
)
...
...
@@ -219,8 +219,8 @@ void __export mempool_clean(mempool_t *pool)
munmap
(
it
,
size
);
else
_free
(
it
);
triton_stat
.
mempool_allocated
-=
size
;
triton_stat
.
mempool_available
-=
size
;
__sync_sub_and_fetch
(
&
triton_stat
.
mempool_allocated
,
size
)
;
__sync_sub_and_fetch
(
&
triton_stat
.
mempool_available
,
size
)
;
}
spin_unlock
(
&
p
->
lock
);
}
...
...
@@ -257,8 +257,8 @@ void sigclean(int num)
munmap
(
it
,
size
);
else
_free
(
it
);
triton_stat
.
mempool_allocated
-=
size
;
triton_stat
.
mempool_available
-=
size
;
__sync_sub_and_fetch
(
&
triton_stat
.
mempool_allocated
,
size
)
;
__sync_sub_and_fetch
(
&
triton_stat
.
mempool_available
,
size
)
;
}
spin_unlock
(
&
p
->
lock
);
}
...
...
accel-pptpd/triton/timer.c
浏览文件 @
369689ab
...
...
@@ -92,6 +92,7 @@ void *timer_thread(void *arg)
if
(
!
t
->
pending
)
{
list_add_tail
(
&
t
->
entry2
,
&
t
->
ctx
->
pending_timers
);
t
->
pending
=
1
;
__sync_add_and_fetch
(
&
triton_stat
.
timer_pending
,
1
);
r
=
triton_queue_ctx
(
t
->
ctx
);
}
else
r
=
0
;
...
...
accel-pptpd/triton/triton.c
浏览文件 @
369689ab
...
...
@@ -62,7 +62,7 @@ static void* triton_thread(struct _triton_thread_t *thread)
thread
->
ctx
->
thread
=
thread
;
thread
->
ctx
->
queued
=
0
;
spin_unlock
(
&
thread
->
ctx
->
lock
);
triton_stat
.
context_pending
--
;
__sync_sub_and_fetch
(
&
triton_stat
.
context_pending
,
1
)
;
}
else
{
log_debug2
(
"thread: %p: sleeping
\n
"
,
thread
);
if
(
!
terminate
)
...
...
@@ -71,11 +71,11 @@ static void* triton_thread(struct _triton_thread_t *thread)
if
(
terminate
)
return
NULL
;
triton_stat
.
thread_active
--
;
__sync_sub_and_fetch
(
&
triton_stat
.
thread_active
,
1
)
;
//printf("thread %p: enter sigwait\n", thread);
sigwait
(
&
set
,
&
sig
);
//printf("thread %p: exit sigwait\n", thread);
triton_stat
.
thread_active
++
;
__sync_add_and_fetch
(
&
triton_stat
.
thread_active
,
1
)
;
if
(
!
thread
->
ctx
)
continue
;
...
...
@@ -141,6 +141,7 @@ static void ctx_thread(struct _triton_context_t *ctx)
list_del
(
&
t
->
entry2
);
t
->
pending
=
0
;
spin_unlock
(
&
ctx
->
lock
);
__sync_sub_and_fetch
(
&
triton_stat
.
timer_pending
,
1
);
read
(
t
->
fd
,
&
tt
,
sizeof
(
tt
));
t
->
ud
->
expire
(
t
->
ud
);
continue
;
...
...
@@ -150,6 +151,7 @@ static void ctx_thread(struct _triton_context_t *ctx)
list_del
(
&
h
->
entry2
);
h
->
pending
=
0
;
spin_unlock
(
&
ctx
->
lock
);
__sync_sub_and_fetch
(
&
triton_stat
.
md_handler_pending
,
1
);
if
(
h
->
trig_epoll_events
&
(
EPOLLIN
|
EPOLLERR
|
EPOLLHUP
))
if
(
h
->
ud
&&
h
->
ud
->
read
)
if
(
h
->
ud
->
read
(
h
->
ud
))
...
...
@@ -197,8 +199,8 @@ struct _triton_thread_t *create_thread()
return
NULL
;
}
triton_stat
.
thread_count
++
;
triton_stat
.
thread_active
++
;
__sync_add_and_fetch
(
&
triton_stat
.
thread_count
,
1
)
;
__sync_add_and_fetch
(
&
triton_stat
.
thread_active
,
1
)
;
return
thread
;
}
...
...
@@ -218,7 +220,7 @@ int triton_queue_ctx(struct _triton_context_t *ctx)
spin_unlock
(
&
threads_lock
);
ctx
->
queued
=
1
;
log_debug2
(
"ctx %p: queued
\n
"
,
ctx
);
triton_stat
.
context_pending
++
;
__sync_add_and_fetch
(
&
triton_stat
.
context_pending
,
1
)
;
return
0
;
}
...
...
@@ -272,8 +274,8 @@ int __export triton_context_register(struct triton_context_t *ud, void *bf_arg)
list_add_tail
(
&
ctx
->
entry
,
&
ctx_list
);
spin_unlock
(
&
ctx_list_lock
);
triton_stat
.
context_sleeping
++
;
triton_stat
.
context_count
++
;
__sync_add_and_fetch
(
&
triton_stat
.
context_sleeping
,
1
)
;
__sync_add_and_fetch
(
&
triton_stat
.
context_count
,
1
)
;
return
0
;
}
...
...
@@ -322,7 +324,7 @@ void __export triton_context_unregister(struct triton_context_t *ud)
terminate
=
1
;
spin_unlock
(
&
ctx_list_lock
);
triton_stat
.
context_count
--
;
__sync_sub_and_fetch
(
&
triton_stat
.
context_count
,
1
)
;
if
(
terminate
)
{
list_for_each_entry
(
t
,
&
threads
,
entry
)
...
...
@@ -352,7 +354,7 @@ void __export triton_context_schedule(struct triton_context_t *ud)
ctx
->
thread
=
NULL
;
spin_unlock
(
&
ctx
->
lock
);
triton_stat
.
context_sleeping
++
;
__sync_add_and_fetch
(
&
triton_stat
.
context_sleeping
,
1
)
;
log_debug2
(
"ctx %p: enter schedule
\n
"
,
ctx
);
if
(
swapcontext
(
&
ctx
->
uctx
,
uctx
))
...
...
@@ -388,7 +390,7 @@ int __export triton_context_wakeup(struct triton_context_t *ud)
if
(
r
)
triton_thread_wakeup
(
ctx
->
thread
);
triton_stat
.
context_sleeping
--
;
__sync_sub_and_fetch
(
&
triton_stat
.
context_sleeping
,
1
)
;
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录