Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
0a31be6b
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0a31be6b
编写于
5月 12, 2009
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix interrupting of main event thread & protect against accidental uniniitalized variables
上级
72dc6d60
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
7 deletion
+41
-7
ChangeLog
ChangeLog
+6
-0
qemud/event.c
qemud/event.c
+35
-7
未找到文件。
ChangeLog
浏览文件 @
0a31be6b
Tue May 12 17:42:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
* qemud/event.c: Start watch/timer IDs from 1 to avoid problem
with accidental uninitialized variables at 0. Fix interrupting
of main thread when updating/deleting watches/timers.
Tue May 12 16:38:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Tue May 12 16:38:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
* qemud/qemud.c, qemud/qemud.h, qemud/event.c: Remove use
* qemud/qemud.c, qemud/qemud.h, qemud/event.c: Remove use
...
...
qemud/event.c
浏览文件 @
0a31be6b
...
@@ -84,10 +84,10 @@ struct virEventLoop {
...
@@ -84,10 +84,10 @@ struct virEventLoop {
static
struct
virEventLoop
eventLoop
;
static
struct
virEventLoop
eventLoop
;
/* Unique ID for the next FD watch to be registered */
/* Unique ID for the next FD watch to be registered */
static
int
nextWatch
=
0
;
static
int
nextWatch
=
1
;
/* Unique ID for the next timer to be registered */
/* Unique ID for the next timer to be registered */
static
int
nextTimer
=
0
;
static
int
nextTimer
=
1
;
static
void
virEventLock
(
void
)
static
void
virEventLock
(
void
)
{
{
...
@@ -143,15 +143,22 @@ int virEventAddHandleImpl(int fd, int events,
...
@@ -143,15 +143,22 @@ int virEventAddHandleImpl(int fd, int events,
void
virEventUpdateHandleImpl
(
int
watch
,
int
events
)
{
void
virEventUpdateHandleImpl
(
int
watch
,
int
events
)
{
int
i
;
int
i
;
EVENT_DEBUG
(
"Update handle w=%d e=%d"
,
watch
,
events
);
if
(
watch
<=
0
)
{
VIR_WARN
(
"Ignoring invalid update watch %d"
,
watch
);
return
;
}
virEventLock
();
virEventLock
();
for
(
i
=
0
;
i
<
eventLoop
.
handlesCount
;
i
++
)
{
for
(
i
=
0
;
i
<
eventLoop
.
handlesCount
;
i
++
)
{
if
(
eventLoop
.
handles
[
i
].
watch
==
watch
)
{
if
(
eventLoop
.
handles
[
i
].
watch
==
watch
)
{
eventLoop
.
handles
[
i
].
events
=
eventLoop
.
handles
[
i
].
events
=
virEventHandleTypeToPollEvent
(
events
);
virEventHandleTypeToPollEvent
(
events
);
virEventInterruptLocked
();
break
;
break
;
}
}
}
}
virEventInterruptLocked
();
virEventUnlock
();
virEventUnlock
();
}
}
...
@@ -164,6 +171,12 @@ void virEventUpdateHandleImpl(int watch, int events) {
...
@@ -164,6 +171,12 @@ void virEventUpdateHandleImpl(int watch, int events) {
int
virEventRemoveHandleImpl
(
int
watch
)
{
int
virEventRemoveHandleImpl
(
int
watch
)
{
int
i
;
int
i
;
EVENT_DEBUG
(
"Remove handle %d"
,
watch
);
EVENT_DEBUG
(
"Remove handle %d"
,
watch
);
if
(
watch
<=
0
)
{
VIR_WARN
(
"Ignoring invalid remove watch %d"
,
watch
);
return
-
1
;
}
virEventLock
();
virEventLock
();
for
(
i
=
0
;
i
<
eventLoop
.
handlesCount
;
i
++
)
{
for
(
i
=
0
;
i
<
eventLoop
.
handlesCount
;
i
++
)
{
if
(
eventLoop
.
handles
[
i
].
deleted
)
if
(
eventLoop
.
handles
[
i
].
deleted
)
...
@@ -172,11 +185,11 @@ int virEventRemoveHandleImpl(int watch) {
...
@@ -172,11 +185,11 @@ int virEventRemoveHandleImpl(int watch) {
if
(
eventLoop
.
handles
[
i
].
watch
==
watch
)
{
if
(
eventLoop
.
handles
[
i
].
watch
==
watch
)
{
EVENT_DEBUG
(
"mark delete %d %d"
,
i
,
eventLoop
.
handles
[
i
].
fd
);
EVENT_DEBUG
(
"mark delete %d %d"
,
i
,
eventLoop
.
handles
[
i
].
fd
);
eventLoop
.
handles
[
i
].
deleted
=
1
;
eventLoop
.
handles
[
i
].
deleted
=
1
;
virEventInterruptLocked
();
virEventUnlock
();
virEventUnlock
();
return
0
;
return
0
;
}
}
}
}
virEventInterruptLocked
();
virEventUnlock
();
virEventUnlock
();
return
-
1
;
return
-
1
;
}
}
...
@@ -232,6 +245,12 @@ void virEventUpdateTimeoutImpl(int timer, int frequency) {
...
@@ -232,6 +245,12 @@ void virEventUpdateTimeoutImpl(int timer, int frequency) {
struct
timeval
tv
;
struct
timeval
tv
;
int
i
;
int
i
;
EVENT_DEBUG
(
"Updating timer %d timeout with %d ms freq"
,
timer
,
frequency
);
EVENT_DEBUG
(
"Updating timer %d timeout with %d ms freq"
,
timer
,
frequency
);
if
(
timer
<=
0
)
{
VIR_WARN
(
"Ignoring invalid update timer %d"
,
timer
);
return
;
}
if
(
gettimeofday
(
&
tv
,
NULL
)
<
0
)
{
if
(
gettimeofday
(
&
tv
,
NULL
)
<
0
)
{
return
;
return
;
}
}
...
@@ -244,10 +263,10 @@ void virEventUpdateTimeoutImpl(int timer, int frequency) {
...
@@ -244,10 +263,10 @@ void virEventUpdateTimeoutImpl(int timer, int frequency) {
frequency
>=
0
?
frequency
+
frequency
>=
0
?
frequency
+
(((
unsigned
long
long
)
tv
.
tv_sec
)
*
1000
)
+
(((
unsigned
long
long
)
tv
.
tv_sec
)
*
1000
)
+
(((
unsigned
long
long
)
tv
.
tv_usec
)
/
1000
)
:
0
;
(((
unsigned
long
long
)
tv
.
tv_usec
)
/
1000
)
:
0
;
virEventInterruptLocked
();
break
;
break
;
}
}
}
}
virEventInterruptLocked
();
virEventUnlock
();
virEventUnlock
();
}
}
...
@@ -260,6 +279,12 @@ void virEventUpdateTimeoutImpl(int timer, int frequency) {
...
@@ -260,6 +279,12 @@ void virEventUpdateTimeoutImpl(int timer, int frequency) {
int
virEventRemoveTimeoutImpl
(
int
timer
)
{
int
virEventRemoveTimeoutImpl
(
int
timer
)
{
int
i
;
int
i
;
EVENT_DEBUG
(
"Remove timer %d"
,
timer
);
EVENT_DEBUG
(
"Remove timer %d"
,
timer
);
if
(
timer
<=
0
)
{
VIR_WARN
(
"Ignoring invalid remove timer %d"
,
timer
);
return
-
1
;
}
virEventLock
();
virEventLock
();
for
(
i
=
0
;
i
<
eventLoop
.
timeoutsCount
;
i
++
)
{
for
(
i
=
0
;
i
<
eventLoop
.
timeoutsCount
;
i
++
)
{
if
(
eventLoop
.
timeouts
[
i
].
deleted
)
if
(
eventLoop
.
timeouts
[
i
].
deleted
)
...
@@ -267,11 +292,11 @@ int virEventRemoveTimeoutImpl(int timer) {
...
@@ -267,11 +292,11 @@ int virEventRemoveTimeoutImpl(int timer) {
if
(
eventLoop
.
timeouts
[
i
].
timer
==
timer
)
{
if
(
eventLoop
.
timeouts
[
i
].
timer
==
timer
)
{
eventLoop
.
timeouts
[
i
].
deleted
=
1
;
eventLoop
.
timeouts
[
i
].
deleted
=
1
;
virEventInterruptLocked
();
virEventUnlock
();
virEventUnlock
();
return
0
;
return
0
;
}
}
}
}
virEventInterruptLocked
();
virEventUnlock
();
virEventUnlock
();
return
-
1
;
return
-
1
;
}
}
...
@@ -617,9 +642,12 @@ static int virEventInterruptLocked(void)
...
@@ -617,9 +642,12 @@ static int virEventInterruptLocked(void)
char
c
=
'\0'
;
char
c
=
'\0'
;
if
(
!
eventLoop
.
running
||
if
(
!
eventLoop
.
running
||
pthread_self
()
==
eventLoop
.
leader
)
pthread_self
()
==
eventLoop
.
leader
)
{
VIR_DEBUG
(
"Skip interrupt, %d %d"
,
eventLoop
.
running
,
(
int
)
eventLoop
.
leader
);
return
0
;
return
0
;
}
VIR_DEBUG0
(
"Interrupting"
);
if
(
safewrite
(
eventLoop
.
wakeupfd
[
1
],
&
c
,
sizeof
(
c
))
!=
sizeof
(
c
))
if
(
safewrite
(
eventLoop
.
wakeupfd
[
1
],
&
c
,
sizeof
(
c
))
!=
sizeof
(
c
))
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录