summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-04-28 23:29:18 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-04-28 23:29:18 +0000
commit3b7232c901f19c49451f5b4894d5c3be82c57d18 (patch)
tree8efd41dffdf3da942c83e38eee51f17c40c13974 /common
parent7a0b255ba127009e7a1b1e00be6cd51387aee1fa (diff)
Fix another watch remove bug
Diffstat (limited to 'common')
-rw-r--r--common/glib-ectomy.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/common/glib-ectomy.c b/common/glib-ectomy.c
index 16992e0f..45f9ce0d 100644
--- a/common/glib-ectomy.c
+++ b/common/glib-ectomy.c
@@ -143,7 +143,7 @@ guint g_io_add_watch_full(GIOChannel *channel, gint priority,
watch->user_data = user_data;
watch->destroy = notify;
- watch->prev = 0;
+ watch->prev = &watch_head;
watch->next = watch_head.next;
if (watch_head.next)
watch_head.next->prev = watch;
@@ -296,17 +296,20 @@ void g_main_loop_run(GMainLoop *loop)
if (rc < 0)
continue;
- for (w = watch_head.next; w; w = n) {
- n = w->next;
- if (*w->revents) {
- gboolean keep = w->func(w->channel, *w->revents, w->user_data);
- if (keep)
- continue;
-
- if (w->destroy)
- w->destroy(w->user_data);
- watch_remove(w);
+ w = watch_head.next;
+ while (w) {
+ if (!*w->revents || w->func(w->channel, *w->revents, w->user_data)) {
+ w = w->next;
+ continue;
}
+
+ n = w->next;
+
+ if (w->destroy)
+ w->destroy(w->user_data);
+ watch_remove(w);
+
+ w = n;
}
/* check expired timers */
@@ -405,3 +408,5 @@ gint g_timeout_remove(const guint id)
return -1;
}
+
+