summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-connection.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-03-14 01:27:58 +0000
committerHavoc Pennington <hp@redhat.com>2003-03-14 01:27:58 +0000
commit3bea935316ff048e68dea6a26c2e8e9fd314477f (patch)
tree498e62121c89d78693070d04e6bc6a6462efe2a7 /dbus/dbus-connection.c
parent81c30364c291045d556c88f6818033104e627b6e (diff)
2003-03-13 Havoc Pennington <hp@redhat.com>
* 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
Diffstat (limited to 'dbus/dbus-connection.c')
-rw-r--r--dbus/dbus-connection.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index bfc27e2a..19fe717d 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -1810,31 +1810,44 @@ dbus_connection_dispatch_message (DBusConnection *connection)
*
* It is not allowed to reference a DBusWatch after it has been passed
* to remove_function.
+ *
+ * If #FALSE is returned due to lack of memory, the failure may be due
+ * to a #FALSE return from the new add_function. If so, the
+ * add_function may have been called successfully one or more times,
+ * but the remove_function will also have been called to remove any
+ * successful adds. i.e. if #FALSE is returned the net result
+ * should be that dbus_connection_set_watch_functions() has no effect,
+ * but the add_function and remove_function may have been called.
*
* @param connection the connection.
* @param add_function function to begin monitoring a new descriptor.
* @param remove_function function to stop monitoring a descriptor.
* @param data data to pass to add_function and remove_function.
* @param free_data_function function to be called to free the data.
+ * @returns #FALSE on failure (no memory)
*/
-void
+dbus_bool_t
dbus_connection_set_watch_functions (DBusConnection *connection,
DBusAddWatchFunction add_function,
DBusRemoveWatchFunction remove_function,
void *data,
DBusFreeFunction free_data_function)
{
+ dbus_bool_t retval;
+
dbus_mutex_lock (connection->mutex);
/* ref connection for slightly better reentrancy */
_dbus_connection_ref_unlocked (connection);
- _dbus_watch_list_set_functions (connection->watches,
- add_function, remove_function,
- data, free_data_function);
+ retval = _dbus_watch_list_set_functions (connection->watches,
+ add_function, remove_function,
+ data, free_data_function);
dbus_mutex_unlock (connection->mutex);
/* drop our paranoid refcount */
dbus_connection_unref (connection);
+
+ return retval;
}
/**
@@ -1855,25 +1868,30 @@ dbus_connection_set_watch_functions (DBusConnection *connection,
* @param remove_function function to remove a timeout.
* @param data data to pass to add_function and remove_function.
* @param free_data_function function to be called to free the data.
+ * @returns #FALSE on failure (no memory)
*/
-void
+dbus_bool_t
dbus_connection_set_timeout_functions (DBusConnection *connection,
DBusAddTimeoutFunction add_function,
DBusRemoveTimeoutFunction remove_function,
void *data,
DBusFreeFunction free_data_function)
{
+ dbus_bool_t retval;
+
dbus_mutex_lock (connection->mutex);
/* ref connection for slightly better reentrancy */
_dbus_connection_ref_unlocked (connection);
- _dbus_timeout_list_set_functions (connection->timeouts,
- add_function, remove_function,
- data, free_data_function);
+ retval = _dbus_timeout_list_set_functions (connection->timeouts,
+ add_function, remove_function,
+ data, free_data_function);
dbus_mutex_unlock (connection->mutex);
/* drop our paranoid refcount */
- dbus_connection_unref (connection);
+ dbus_connection_unref (connection);
+
+ return retval;
}
/**