From 3bea935316ff048e68dea6a26c2e8e9fd314477f Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Fri, 14 Mar 2003 01:27:58 +0000 Subject: 2003-03-13 Havoc Pennington * dbus/dbus-timeout.c (_dbus_timeout_list_set_functions): handle out of memory * dbus/dbus-watch.c (_dbus_watch_list_set_functions): handle out of memory * dbus/dbus-connection.h: Make AddWatchFunction and AddTimeoutFunction return a bool so they can fail on out-of-memory * bus/bus.c (bus_context_new): set up timeout handlers * bus/connection.c (bus_connections_setup_connection): set up timeout handlers * glib/dbus-gmain.c: adapt to the fact that set_functions stuff can fail * bus/bus.c (bus_context_new): adapt to changes * bus/connection.c: adapt to changes * test/watch.c: adapt to DBusWatch changes * bus/dispatch.c (bus_dispatch_test): started adding this but didn't finish --- glib/dbus-gmain.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'glib') diff --git a/glib/dbus-gmain.c b/glib/dbus-gmain.c index 40523738..b0ec7c4b 100644 --- a/glib/dbus-gmain.c +++ b/glib/dbus-gmain.c @@ -231,7 +231,7 @@ dbus_server_dispatch (GSource *source, return TRUE; } -static void +static dbus_bool_t add_watch (DBusWatch *watch, gpointer data) { @@ -257,6 +257,8 @@ add_watch (DBusWatch *watch, dbus_source->poll_fds = g_list_prepend (dbus_source->poll_fds, poll_fd); g_hash_table_insert (dbus_source->watches, poll_fd, watch); + + return TRUE; } static void @@ -285,7 +287,7 @@ timeout_handler (gpointer data) return FALSE; } -static void +static dbus_bool_t add_timeout (DBusTimeout *timeout, void *data) { @@ -295,6 +297,8 @@ add_timeout (DBusTimeout *timeout, timeout_handler, timeout); dbus_timeout_set_data (timeout, GUINT_TO_POINTER (timeout_tag), NULL); + + return TRUE; } static void @@ -356,16 +360,18 @@ dbus_connection_setup_with_g_main (DBusConnection *connection) source = create_source (connection, &dbus_connection_funcs); - dbus_connection_set_watch_functions (connection, - add_watch, - remove_watch, - source, NULL); + if (!dbus_connection_set_watch_functions (connection, + add_watch, + remove_watch, + source, NULL)) + goto nomem; - dbus_connection_set_timeout_functions (connection, - add_timeout, - remove_timeout, - NULL, NULL); - + if (!dbus_connection_set_timeout_functions (connection, + add_timeout, + remove_timeout, + NULL, NULL)) + goto nomem; + dbus_connection_set_wakeup_main_function (connection, wakeup_main, NULL, NULL); -- cgit