From 17b9d565bbc60edc5b324cff41df5834b8159ed3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 21 Jan 2011 16:49:14 +0000 Subject: [PATCH 2/2] Check that watches are removed, then invalidated, then unreffed --- dbus/dbus-mainloop.c | 6 +++++- dbus/dbus-watch.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index 43159a7..b7e7b37 100644 --- a/dbus/dbus-mainloop.c +++ b/dbus/dbus-mainloop.c @@ -290,7 +290,11 @@ _dbus_loop_remove_watch (DBusLoop *loop, void *data) { DBusList *link; - + + /* fd.o #33336: we want people to remove their watches before invalidating + * them */ + _dbus_assert (dbus_watch_get_socket (watch) != -1); + link = _dbus_list_get_first_link (&loop->callbacks); while (link != NULL) { diff --git a/dbus/dbus-watch.c b/dbus/dbus-watch.c index 8d759e5..f4a5820 100644 --- a/dbus/dbus-watch.c +++ b/dbus/dbus-watch.c @@ -129,6 +129,9 @@ _dbus_watch_unref (DBusWatch *watch) watch->refcount -= 1; if (watch->refcount == 0) { + if (watch->fd != -1) + _dbus_warn ("this watch should have been invalidated"); + dbus_watch_set_data (watch, NULL, NULL); /* call free_data_function */ if (watch->free_handler_data_function) -- 1.7.2.3