so the kernel can send d-bus messages

Olivier Andrieu oliv__a at users.sourceforge.net
Sun Jul 25 03:40:58 PDT 2004


 Havoc Pennington [Sat, 24 Jul 2004]:
 > To support dbus-daemon restarts, we could take a similar approach
 > in the libdbus API by forcing apps to be written async, i.e. make
 > dbus_connection_open() async, along with dbus_bus_get(); then app
 > authors have to write a connection_established_callback() which
 > could reasonably be called multiple times.

Isn't the Disonnected signal enough for this already ?
Or you just want to make this style mandatory ?


static DBusConnection *conn;

void establish_connection ()
{
  if (conn != NULL)
    dbus_connection_unref (conn);
  conn = dbus_bus_get (DBUS_BUS_SYSTEM);
  bus_connection_add_filter (conn, trap_disconnected, NULL, NULL);
  ....
}

DBusHandlerResult 
trap_disconnected (DBusConnection *conn, 
		   DBusMessage *msg, void *data)
{
  if (dbus_message_is_signal (msg,
			      DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL,
			      "Disconnected"))
    {
      /* re-connect right away */
      establish_connection ();
      return DBUS_HANDLER_RESULT_HANDLED;
    }
  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}

-- 
   Olivier


More information about the dbus mailing list