Tracking whether a connection is alive

David Zeuthen david at fubar.dk
Sun Jul 11 14:50:11 PDT 2004


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?

Thanks,
David

[1] : for a multitude of reasons actually; go Google for magicdev and cd
burning problems; HAL polls just like magicdev, we've have to thanks to
broken hardware out there. So, the solution is that if someone locks the
device represent a CD-R we don't poll, and presto, problem solved.





More information about the dbus mailing list