diff options
| author | Havoc Pennington <hp@redhat.com> | 2003-03-14 01:27:58 +0000 | 
|---|---|---|
| committer | Havoc Pennington <hp@redhat.com> | 2003-03-14 01:27:58 +0000 | 
| commit | 3bea935316ff048e68dea6a26c2e8e9fd314477f (patch) | |
| tree | 498e62121c89d78693070d04e6bc6a6462efe2a7 /bus/connection.c | |
| parent | 81c30364c291045d556c88f6818033104e627b6e (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 'bus/connection.c')
| -rw-r--r-- | bus/connection.c | 77 | 
1 files changed, 61 insertions, 16 deletions
| diff --git a/bus/connection.c b/bus/connection.c index cdc8be79..f0463392 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -108,11 +108,18 @@ bus_connection_disconnected (DBusConnection *connection)    bus_dispatch_remove_connection (connection);    /* no more watching */ -  dbus_connection_set_watch_functions (connection, -                                       NULL, NULL, -                                       connection, -                                       NULL); - +  if (!dbus_connection_set_watch_functions (connection, +                                            NULL, NULL, +                                            connection, +                                            NULL)) +    _dbus_assert_not_reached ("setting watch functions to NULL failed"); + +  if (!dbus_connection_set_timeout_functions (connection, +                                              NULL, NULL, +                                              connection, +                                              NULL)) +    _dbus_assert_not_reached ("setting timeout functions to NULL failed"); +      bus_connection_remove_transactions (connection);    _dbus_list_remove (&d->connections->list, connection); @@ -140,12 +147,12 @@ connection_watch_callback (DBusWatch     *watch,    dbus_connection_unref (connection);  } -static void +static dbus_bool_t  add_connection_watch (DBusWatch      *watch,                        DBusConnection *connection)  { -  bus_loop_add_watch (watch, connection_watch_callback, connection, -                      NULL); +  return bus_loop_add_watch (watch, connection_watch_callback, connection, +                             NULL);  }  static void @@ -156,6 +163,27 @@ remove_connection_watch (DBusWatch      *watch,  }  static void +connection_timeout_callback (DBusTimeout   *timeout, +                             void          *data) +{ +  dbus_timeout_handle (timeout); +} + +static dbus_bool_t +add_connection_timeout (DBusTimeout    *timeout, +                        DBusConnection *connection) +{ +  return bus_loop_add_timeout (timeout, connection_timeout_callback, connection, NULL); +} + +static void +remove_connection_timeout (DBusTimeout    *timeout, +                           DBusConnection *connection) +{ +  bus_loop_remove_timeout (timeout, connection_timeout_callback, connection); +} + +static void  free_connection_data (void *data)  {    BusConnectionData *d = data; @@ -249,18 +277,35 @@ bus_connections_setup_connection (BusConnections *connections,        dbus_connection_disconnect (connection);        return FALSE;      } - -  dbus_connection_ref (connection); -  dbus_connection_set_watch_functions (connection, -                                       (DBusAddWatchFunction) add_connection_watch, -                                       (DBusRemoveWatchFunction) remove_connection_watch, -                                       connection, -                                       NULL); +  if (!dbus_connection_set_watch_functions (connection, +                                            (DBusAddWatchFunction) add_connection_watch, +                                            (DBusRemoveWatchFunction) remove_connection_watch, +                                            connection, +                                            NULL)) +    { +      dbus_connection_disconnect (connection); +      return FALSE; +    } +   +  if (!dbus_connection_set_timeout_functions (connection, +                                              (DBusAddTimeoutFunction) add_connection_timeout, +                                              (DBusRemoveTimeoutFunction) remove_connection_timeout, +                                              connection, NULL)) +    { +      dbus_connection_disconnect (connection); +      return FALSE; +    } +    /* Setup the connection with the dispatcher */    if (!bus_dispatch_add_connection (connection)) -    return FALSE; +    { +      dbus_connection_disconnect (connection); +      return FALSE; +    } + +  dbus_connection_ref (connection);    return TRUE;  } | 
