aboutsummaryrefslogtreecommitdiff
path: root/util/main-loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/main-loop.c')
-rw-r--r--util/main-loop.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/util/main-loop.c b/util/main-loop.c
index de38876064..10fa74c6e3 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -373,10 +373,20 @@ static WaitObjects wait_objects = {0};
int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)
{
+ int i;
WaitObjects *w = &wait_objects;
+
if (w->num >= MAXIMUM_WAIT_OBJECTS) {
return -1;
}
+
+ for (i = 0; i < w->num; i++) {
+ /* check if the same handle is added twice */
+ if (w->events[i] == handle) {
+ return -1;
+ }
+ }
+
w->events[w->num] = handle;
w->func[w->num] = func;
w->opaque[w->num] = opaque;