Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
9a867164
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9a867164
编写于
2月 06, 2009
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix 100% libvirt CPU usage when --timeout is set
上级
31135bff
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
20 deletion
+48
-20
ChangeLog
ChangeLog
+10
-0
qemud/event.c
qemud/event.c
+6
-2
qemud/qemud.c
qemud/qemud.c
+32
-18
未找到文件。
ChangeLog
浏览文件 @
9a867164
Fri Feb 6 14:43:10 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
Fix 100% CPU bound loop when libvirtd --timeout is used
* qemud/event.c: Don't assume pthread_t is equivalent to an
int, explicitly track whether event loop is active with a
flag independantly of the threadLeader variable
* qemud/qemud.c: Don't register/unregister shutdown timer
on each loop. Register once, and activate/deactivate when
required
Thu Feb 5 19:28:10 GMT 2009 John Levon <john.levon@sun.com>
* src/domain_conf.c: Check the last error, not the last
...
...
qemud/event.c
浏览文件 @
9a867164
...
...
@@ -68,6 +68,7 @@ struct virEventTimeout {
/* State for the main event loop */
struct
virEventLoop
{
pthread_mutex_t
lock
;
int
running
;
pthread_t
leader
;
int
wakeupfd
[
2
];
int
handlesCount
;
...
...
@@ -521,6 +522,7 @@ int virEventRunOnce(void) {
int
ret
,
timeout
,
nfds
;
virEventLock
();
eventLoop
.
running
=
1
;
eventLoop
.
leader
=
pthread_self
();
if
((
nfds
=
virEventMakePollFDs
(
&
fds
))
<
0
)
{
virEventUnlock
();
...
...
@@ -572,7 +574,7 @@ int virEventRunOnce(void) {
return
-
1
;
}
eventLoop
.
leader
=
0
;
eventLoop
.
running
=
0
;
virEventUnlock
();
return
0
;
}
...
...
@@ -611,7 +613,9 @@ int virEventInit(void)
static
int
virEventInterruptLocked
(
void
)
{
char
c
=
'\0'
;
if
(
pthread_self
()
==
eventLoop
.
leader
)
if
(
!
eventLoop
.
running
||
pthread_self
()
==
eventLoop
.
leader
)
return
0
;
if
(
safewrite
(
eventLoop
.
wakeupfd
[
1
],
&
c
,
sizeof
(
c
))
!=
sizeof
(
c
))
...
...
qemud/qemud.c
浏览文件 @
9a867164
...
...
@@ -2031,11 +2031,15 @@ static int qemudOneLoop(void) {
return
0
;
}
static
void
qemudInactiveTimer
(
int
timer
ATTRIBUTE_UNUSED
,
void
*
data
)
{
static
void
qemudInactiveTimer
(
int
timer
id
,
void
*
data
)
{
struct
qemud_server
*
server
=
(
struct
qemud_server
*
)
data
;
DEBUG0
(
"Got inactive timer expiry"
);
if
(
!
virStateActive
())
{
DEBUG0
(
"No state active, shutting down"
);
if
(
virStateActive
()
||
server
->
clients
)
{
DEBUG0
(
"Timer expired but still active, not shutting down"
);
virEventUpdateTimeoutImpl
(
timerid
,
-
1
);
}
else
{
DEBUG0
(
"Timer expired and inactive, shutting down"
);
server
->
shutdown
=
1
;
}
}
...
...
@@ -2066,9 +2070,18 @@ static void qemudFreeClient(struct qemud_client *client) {
static
int
qemudRunLoop
(
struct
qemud_server
*
server
)
{
int
timerid
=
-
1
;
int
ret
=
-
1
,
i
;
int
timerActive
=
0
;
virMutexLock
(
&
server
->
lock
);
if
(
timeout
>
0
&&
(
timerid
=
virEventAddTimeoutImpl
(
-
1
,
qemudInactiveTimer
,
server
,
NULL
))
<
0
)
{
VIR_ERROR0
(
_
(
"Failed to register shutdown timeout"
));
return
-
1
;
}
if
(
min_workers
>
max_workers
)
max_workers
=
min_workers
;
...
...
@@ -2089,11 +2102,21 @@ static int qemudRunLoop(struct qemud_server *server) {
* if any drivers have active state, if not
* shutdown after timeout seconds
*/
if
(
timeout
>
0
&&
!
virStateActive
()
&&
!
server
->
clients
)
{
timerid
=
virEventAddTimeoutImpl
(
timeout
*
1000
,
qemudInactiveTimer
,
server
,
NULL
);
DEBUG
(
"Scheduling shutdown timer %d"
,
timerid
);
if
(
timeout
>
0
)
{
if
(
timerActive
)
{
if
(
server
->
clients
)
{
DEBUG
(
"Deactivating shutdown timer %d"
,
timerid
);
virEventUpdateTimeoutImpl
(
timerid
,
-
1
);
timerActive
=
0
;
}
}
else
{
if
(
!
virStateActive
()
&&
!
server
->
clients
)
{
DEBUG
(
"Activating shutdown timer %d"
,
timerid
);
virEventUpdateTimeoutImpl
(
timerid
,
timeout
*
1000
);
timerActive
=
1
;
}
}
}
virMutexUnlock
(
&
server
->
lock
);
...
...
@@ -2147,15 +2170,6 @@ static int qemudRunLoop(struct qemud_server *server) {
}
}
/* Unregister any timeout that's active, since we
* just had an event processed
*/
if
(
timerid
!=
-
1
)
{
DEBUG
(
"Removing shutdown timer %d"
,
timerid
);
virEventRemoveTimeoutImpl
(
timerid
);
timerid
=
-
1
;
}
if
(
server
->
shutdown
)
{
ret
=
0
;
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录