Tracking whether a connection is alive

David Zeuthen david at
Sun Jul 11 15:20:38 PDT 2004

On Mon, 2004-07-12 at 00:17 +0200, Kay Sievers wrote:
> On Sun, 2004-07-11 at 23:50 +0200, David Zeuthen wrote:
> > Hi,
> > 
> > I'm looking for a way to determine if another peer on the system bus is
> > alive; maybe it's easier if I describe what I want achieve; in HAL, I
> > want to implement locking of devices - this is useful for obtaining
> > exclusive access to a device, which is quite useful for e.g. CD
> > recording [1]. 
> > 
> > So, on the interface org.freedesktop.Hal.Device I want to implement the
> > method AcquireLock() and applications might call this on the /org/
> > freedesktop/Hal/devices/cdr_burner-disc object. It might throw an
> > exception if the lock cannot be acquired, e.g. if someone else got the
> > lock. There will be a corresponding ReleaseLock() method. Pretty
> > standard.
> > 
> > Now, the potential problem I see here if an application holding the lock
> > is either crashing or it locks up - because then it doesn't release the
> > lock and we're screwed.
> > 
> > So, it seems that I need to keep track of the DBusConnection holding the
> > lock and somehow either a) ping it every e.g. 5 seconds; or b) require
> > the DBusConnection to invoke a method e.g. StillGotLock() every e.g. 5
> > seconds. Hmm..
> > 
> > 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?
> What about this?
> "You could think of the base service names as IP addresses, and the
> well-known services as domain names. So com.mycompany.TextEditor might
> map to something like :34-907 just as maps to something
> like 
> Services have a second important use, other than routing messages. They
> are used to track lifecycle. When an application exits (or crashes), its
> connection to the message bus will be closed by the operating system
> kernel. The message bus then sends out notification messages telling
> remaining applications that the application's services have lost their
> owner. By tracking these notifications, your application can reliably
> monitor the lifetime of other applications."

Close, but not close enough. 

What if an application locks up? I've tried that with K3B actually. I
guess what I'm asking for is that the system message bus pings all
connections regularly, like, say every five seconds or so.


More information about the dbus mailing list