Tracking whether a connection is alive
David Zeuthen
david at fubar.dk
Sun Jul 11 15:31:27 PDT 2004
On Sun, 2004-07-11 at 23:26 +0100, Daniel Silverstone wrote:
> David Zeuthen wrote:
> > Is there any easier or more general way to do this? Can the problem be
> > solved in a general way that may be useful for other applications of D-
> > BUS?
>
> When you process the AcquireLock() method... obtain the base service of the
> caller using dbus_message_get_sender().
>
> Add a matcher to your connection similar to:
>
> dbus_bus_add_match( connection,
> "interface='org.freedesktop.DBus',member='ServiceDeleted'", NULL );
>
> Then, in your filter function...
>
> if( dbus_message_is_signal( message,
> "org.freedesktop.DBus",
> "ServiceDeleted" ) ) {
> /* code to forcibly release the lock*/
> }
>
> I hope that helps.
>
This definitely seems like the way it should be done.
But I don't see this covering the case where the app getting the lock,
locks up. Unless the system message bus actively pings said app on a
regular schedule and then deletes the service if it doesn't respond.
Which is kind of ugly. Which is why I may have to do that in HAL instead
of relying on D-BUS to do it for me.
Thanks,
David
More information about the dbus
mailing list