summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--async.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/async.c b/async.c
index 9d4e960b02..ca13962222 100644
--- a/async.c
+++ b/async.c
@@ -55,6 +55,9 @@ int qemu_bh_poll(void)
{
QEMUBH *bh, **bhp, *next;
int ret;
+ static int nesting = 0;
+
+ nesting++;
ret = 0;
for (bh = first_bh; bh; bh = next) {
@@ -68,15 +71,20 @@ int qemu_bh_poll(void)
}
}
+ nesting--;
+
/* remove deleted bhs */
- bhp = &first_bh;
- while (*bhp) {
- bh = *bhp;
- if (bh->deleted) {
- *bhp = bh->next;
- g_free(bh);
- } else
- bhp = &bh->next;
+ if (!nesting) {
+ bhp = &first_bh;
+ while (*bhp) {
+ bh = *bhp;
+ if (bh->deleted) {
+ *bhp = bh->next;
+ g_free(bh);
+ } else {
+ bhp = &bh->next;
+ }
+ }
}
return ret;