From c5c78507621256b73e434443739584b769bb317b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 21 Jan 2011 16:49:14 +0000 Subject: [PATCH] Check that watches are removed, then invalidated, then unreffed Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33336 Reviewed-by: Will Thompson Reviewed-by: Thiago Macieira --- dbus/dbus-mainloop.c | 6 +++++- dbus/dbus-watch.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index 03e9d1c1..a25b31d6 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 8d759e5e..f4a5820e 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)