From: Simon McVittie Date: Fri, 21 Jan 2011 16:49:14 +0000 (+0000) Subject: Check that watches are removed, then invalidated, then unreffed X-Git-Tag: dbus-1.5.6~107 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c5c78507621256b73e434443739584b769bb317b;p=thirdparty%2Fdbus.git 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 --- diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index 03e9d1c18..a25b31d60 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 8d759e5e3..f4a5820ee 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)