Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Achou.Wang
accel-ppp
提交
f7b2b5c9
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,体验更适合开发者的 AI 搜索 >>
提交
f7b2b5c9
编写于
5月 18, 2014
作者:
D
Dmitry Kozlov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
triton: fix possible race
上级
34751881
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
6 deletion
+15
-6
accel-pppd/triton/md.c
accel-pppd/triton/md.c
+2
-0
accel-pppd/triton/timer.c
accel-pppd/triton/timer.c
+3
-5
accel-pppd/triton/triton.c
accel-pppd/triton/triton.c
+8
-1
accel-pppd/triton/triton_p.h
accel-pppd/triton/triton_p.h
+2
-0
未找到文件。
accel-pppd/triton/md.c
浏览文件 @
f7b2b5c9
...
...
@@ -100,6 +100,7 @@ static void *md_thread(void *arg)
while
(
!
list_empty
(
&
freed_list2
))
{
h
=
list_entry
(
freed_list2
.
next
,
typeof
(
*
h
),
entry
);
list_del
(
&
h
->
entry
);
triton_context_release
(
h
->
ctx
);
mempool_free
(
h
);
}
...
...
@@ -125,6 +126,7 @@ void __export triton_md_register_handler(struct triton_context_t *ctx, struct tr
h
->
ctx
=
(
struct
_triton_context_t
*
)
ctx
->
tpd
;
else
h
->
ctx
=
(
struct
_triton_context_t
*
)
default_ctx
.
tpd
;
__sync_add_and_fetch
(
&
h
->
ctx
->
refs
,
1
);
ud
->
tpd
=
h
;
spin_lock
(
&
h
->
ctx
->
lock
);
list_add_tail
(
&
h
->
entry
,
&
h
->
ctx
->
handlers
);
...
...
accel-pppd/triton/timer.c
浏览文件 @
f7b2b5c9
...
...
@@ -107,15 +107,12 @@ void *timer_thread(void *arg)
while
(
!
list_empty
(
&
freed_list2
))
{
t
=
list_entry
(
freed_list2
.
next
,
typeof
(
*
t
),
entry
);
list_del
(
&
t
->
entry
);
triton_context_release
(
t
->
ctx
);
mempool_free
(
t
);
}
pthread_mutex_lock
(
&
freed_list_lock
);
while
(
!
list_empty
(
&
freed_list
))
{
t
=
list_entry
(
freed_list
.
next
,
typeof
(
*
t
),
entry
);
list_del
(
&
t
->
entry
);
list_add
(
&
t
->
entry
,
&
freed_list2
);
}
list_splice_init
(
&
freed_list
,
&
freed_list2
);
pthread_mutex_unlock
(
&
freed_list_lock
);
}
...
...
@@ -147,6 +144,7 @@ int __export triton_timer_add(struct triton_context_t *ctx, struct triton_timer_
goto
out_err
;
}
__sync_add_and_fetch
(
&
t
->
ctx
->
refs
,
1
);
ud
->
tpd
=
t
;
if
(
triton_timer_mod
(
ud
,
abs_time
))
...
...
accel-pppd/triton/triton.c
浏览文件 @
f7b2b5c9
...
...
@@ -169,7 +169,7 @@ cont:
if
(
thread
->
ctx
->
need_free
)
{
log_debug2
(
"- context %p removed
\n
"
,
thread
->
ctx
);
mempool_fre
e
(
thread
->
ctx
);
triton_context_releas
e
(
thread
->
ctx
);
}
thread
->
ctx
=
NULL
;
...
...
@@ -296,6 +296,12 @@ int triton_queue_ctx(struct _triton_context_t *ctx)
return
1
;
}
void
triton_context_release
(
struct
_triton_context_t
*
ctx
)
{
if
(
__sync_sub_and_fetch
(
&
ctx
->
refs
,
1
)
==
0
)
mempool_free
(
ctx
);
}
int
__export
triton_context_register
(
struct
triton_context_t
*
ud
,
void
*
bf_arg
)
{
struct
_triton_context_t
*
ctx
=
mempool_alloc
(
ctx_pool
);
...
...
@@ -308,6 +314,7 @@ int __export triton_context_register(struct triton_context_t *ud, void *bf_arg)
ctx
->
ud
=
ud
;
ctx
->
bf_arg
=
bf_arg
;
ctx
->
init
=
1
;
ctx
->
refs
=
1
;
spinlock_init
(
&
ctx
->
lock
);
INIT_LIST_HEAD
(
&
ctx
->
handlers
);
INIT_LIST_HEAD
(
&
ctx
->
timers
);
...
...
accel-pppd/triton/triton_p.h
浏览文件 @
f7b2b5c9
...
...
@@ -41,6 +41,7 @@ struct _triton_context_t
int
need_free
;
int
pending
;
int
priority
;
int
refs
;
struct
triton_context_t
*
ud
;
void
*
bf_arg
;
...
...
@@ -107,5 +108,6 @@ int conf_reload(const char *fname);
void
triton_log_error
(
const
char
*
fmt
,
...)
__attribute__
((
format
(
gnu_printf
,
1
,
2
)));
void
triton_log_debug
(
const
char
*
fmt
,
...)
__attribute__
((
format
(
gnu_printf
,
1
,
2
)));
int
load_modules
(
const
char
*
name
);
void
triton_context_release
(
struct
_triton_context_t
*
ctx
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录