Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
470317f5
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看板
提交
470317f5
编写于
5月 12, 2009
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix watch/timer event deletion
上级
0a31be6b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
58 addition
and
61 deletion
+58
-61
ChangeLog
ChangeLog
+7
-0
qemud/event.c
qemud/event.c
+51
-61
未找到文件。
ChangeLog
浏览文件 @
470317f5
Tue May 12 17:43:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Fix watch/timer event deletion
* qemud/event.c: Change handling of deleted watches/timers
to ensure correct dispatch of callbacks when deleted flag
is set
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
...
...
qemud/event.c
浏览文件 @
470317f5
...
...
@@ -313,7 +313,7 @@ static int virEventCalculateTimeout(int *timeout) {
EVENT_DEBUG
(
"Calculate expiry of %d timers"
,
eventLoop
.
timeoutsCount
);
/* Figure out if we need a timeout */
for
(
i
=
0
;
i
<
eventLoop
.
timeoutsCount
;
i
++
)
{
if
(
eventLoop
.
timeouts
[
i
].
deleted
||
eventLoop
.
timeouts
[
i
].
frequency
<
0
)
if
(
eventLoop
.
timeouts
[
i
].
frequency
<
0
)
continue
;
EVENT_DEBUG
(
"Got a timeout scheduled for %llu"
,
eventLoop
.
timeouts
[
i
].
expiresAt
);
...
...
@@ -350,32 +350,26 @@ static int virEventCalculateTimeout(int *timeout) {
* file handles. The caller must free the returned data struct
* returns: the pollfd array, or NULL on error
*/
static
int
virEventMakePollFDs
(
struct
pollfd
**
retfds
)
{
static
struct
pollfd
*
virEventMakePollFDs
(
void
)
{
struct
pollfd
*
fds
;
int
i
,
nfds
=
0
;
int
i
;
for
(
i
=
0
;
i
<
eventLoop
.
handlesCount
;
i
++
)
{
if
(
eventLoop
.
handles
[
i
].
deleted
)
continue
;
nfds
++
;
}
*
retfds
=
NULL
;
/* Setup the poll file handle data structs */
if
(
VIR_ALLOC_N
(
fds
,
nfds
)
<
0
)
return
-
1
;
if
(
VIR_ALLOC_N
(
fds
,
eventLoop
.
handlesCount
)
<
0
)
return
NULL
;
for
(
i
=
0
,
nfds
=
0
;
i
<
eventLoop
.
handlesCount
;
i
++
)
{
if
(
eventLoop
.
handles
[
i
].
deleted
)
continue
;
fds
[
nfds
].
fd
=
eventLoop
.
handles
[
i
].
fd
;
fds
[
nfds
].
events
=
eventLoop
.
handles
[
i
].
events
;
fds
[
nfds
].
revents
=
0
;
for
(
i
=
0
;
i
<
eventLoop
.
handlesCount
;
i
++
)
{
EVENT_DEBUG
(
"Prepare n=%d w=%d, f=%d e=%d"
,
i
,
eventLoop
.
handles
[
i
].
watch
,
eventLoop
.
handles
[
i
].
fd
,
eventLoop
.
handles
[
i
].
events
);
fds
[
i
].
fd
=
eventLoop
.
handles
[
i
].
fd
;
fds
[
i
].
events
=
eventLoop
.
handles
[
i
].
events
;
fds
[
i
].
revents
=
0
;
//EVENT_DEBUG("Wait for %d %d", eventLoop.handles[i].fd, eventLoop.handles[i].events);
nfds
++
;
}
*
retfds
=
fds
;
return
nfds
;
return
fds
;
}
...
...
@@ -435,26 +429,30 @@ static int virEventDispatchTimeouts(void) {
* Returns 0 upon success, -1 if an error occurred
*/
static
int
virEventDispatchHandles
(
int
nfds
,
struct
pollfd
*
fds
)
{
int
i
,
n
;
int
i
;
for
(
i
=
0
,
n
=
0
;
i
<
eventLoop
.
handlesCount
&&
n
<
nfds
;
i
++
)
{
/* NB, use nfds not eventLoop.handlesCount, because new
* fds might be added on end of list, and they're not
* in the fds array we've got */
for
(
i
=
0
;
i
<
nfds
;
i
++
)
{
if
(
eventLoop
.
handles
[
i
].
deleted
)
{
EVENT_DEBUG
(
"Skip deleted %d"
,
eventLoop
.
handles
[
i
].
fd
);
EVENT_DEBUG
(
"Skip deleted n=%d w=%d f=%d"
,
i
,
eventLoop
.
handles
[
i
].
watch
,
eventLoop
.
handles
[
i
].
fd
);
continue
;
}
if
(
fds
[
n
].
revents
)
{
if
(
fds
[
i
].
revents
)
{
virEventHandleCallback
cb
=
eventLoop
.
handles
[
i
].
cb
;
void
*
opaque
=
eventLoop
.
handles
[
i
].
opaque
;
int
hEvents
=
virPollEventToEventHandleType
(
fds
[
n
].
revents
);
EVENT_DEBUG
(
"Dispatch %d %d %p"
,
fds
[
n
].
fd
,
fds
[
n
].
revents
,
eventLoop
.
handles
[
i
].
opaque
);
int
hEvents
=
virPollEventToEventHandleType
(
fds
[
i
].
revents
);
EVENT_DEBUG
(
"Dispatch n=%d f=%d w=%d e=%d %p"
,
i
,
fds
[
i
].
fd
,
eventLoop
.
handles
[
i
].
watch
,
fds
[
i
].
revents
,
eventLoop
.
handles
[
i
].
opaque
);
virEventUnlock
();
(
cb
)(
eventLoop
.
handles
[
i
].
watch
,
fds
[
n
].
fd
,
hEvents
,
opaque
);
fds
[
i
].
fd
,
hEvents
,
opaque
);
virEventLock
();
}
n
++
;
}
return
0
;
...
...
@@ -545,22 +543,21 @@ static int virEventCleanupHandles(void) {
* at least one file handle has an event, or a timer expires
*/
int
virEventRunOnce
(
void
)
{
struct
pollfd
*
fds
;
struct
pollfd
*
fds
=
NULL
;
int
ret
,
timeout
,
nfds
;
virEventLock
();
eventLoop
.
running
=
1
;
eventLoop
.
leader
=
pthread_self
();
if
((
nfds
=
virEventMakePollFDs
(
&
fds
))
<
0
)
{
virEventUnlock
();
return
-
1
;
}
if
(
virEventCalculateTimeout
(
&
timeout
)
<
0
)
{
VIR_FREE
(
fds
);
virEventUnlock
();
return
-
1
;
}
if
(
virEventCleanupTimeouts
()
<
0
||
virEventCleanupHandles
()
<
0
)
goto
error
;
if
(
!
(
fds
=
virEventMakePollFDs
())
||
virEventCalculateTimeout
(
&
timeout
)
<
0
)
goto
error
;
nfds
=
eventLoop
.
handlesCount
;
virEventUnlock
();
...
...
@@ -572,38 +569,31 @@ int virEventRunOnce(void) {
if
(
errno
==
EINTR
)
{
goto
retry
;
}
VIR_FREE
(
fds
);
return
-
1
;
goto
error_unlocked
;
}
virEventLock
();
if
(
virEventDispatchTimeouts
()
<
0
)
{
VIR_FREE
(
fds
);
virEventUnlock
();
return
-
1
;
}
if
(
virEventDispatchTimeouts
()
<
0
)
goto
error
;
if
(
ret
>
0
&&
virEventDispatchHandles
(
nfds
,
fds
)
<
0
)
{
VIR_FREE
(
fds
);
virEventUnlock
();
return
-
1
;
}
VIR_FREE
(
fds
);
if
(
virEventCleanupTimeouts
()
<
0
)
{
virEventUnlock
();
return
-
1
;
}
virEventDispatchHandles
(
nfds
,
fds
)
<
0
)
goto
error
;
if
(
virEventCleanupHandles
()
<
0
)
{
virEventUnlock
();
return
-
1
;
}
if
(
virEventCleanupTimeouts
()
<
0
||
virEventCleanupHandles
()
<
0
)
goto
error
;
eventLoop
.
running
=
0
;
virEventUnlock
();
VIR_FREE
(
fds
);
return
0
;
error:
virEventUnlock
();
error_unlocked:
VIR_FREE
(
fds
);
return
-
1
;
}
static
void
virEventHandleWakeup
(
int
watch
ATTRIBUTE_UNUSED
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录