[avahi] Race condition using the avahi D-Bus interface?

Danny Smit danny.smit.0 at gmail.com
Wed Dec 24 01:12:35 PST 2014


Thanks for your input. Could it be related to the fact that in my case
the event loop is already started, before the browser is instantiated
and the signals are connected?

I tried the python browse example shown here:
http://avahi.org/wiki/Bindings, it seems to work perfectly well, just
like you said. However in the that case the signals are connected
before the eventloop is up and running. Therefore there is no chance
that events get lost before the signals are connected.

In my case however the eventloop is already up and running, which
makes wonder if that could be the reason that events seem to get lost.

On Tue, Dec 23, 2014 at 5:27 PM,  <amo.vanbemten at student.ulg.ac.be> wrote:
> Hi,
>
> I'm applying a similar approach and I have no problems.
> My code:
>
> try:
>   path_to_browser = self.server.ServiceBrowserNew(interface,
>                                                   protocol,
>                                                   stype,
>                                                   domain,
>                                                   dbus.UInt32(0))
>   proxy = self.bus.get_object(bus_name = avahi.DBUS_NAME,
>                               object_path = path_to_browser)
>   ifc = dbus.Interface(proxy, avahi.DBUS_INTERFACE_SERVICE_BROWSER)
> except DBusException as e:
>   self.stop(error = "Error with the Avahi daemon. Is it still running? " +
>                      "Error : %s." % e)
>   return
>
> ifc.connect_to_signal('ItemNew', self.newService)
> ifc.connect_to_signal('ItemRemove', self.removeService)
>
>
> does not suffer of race conditions problems. I've been testing
> it on networks with hundreds of services and I apply such a
> scheme several times (creating a ServiceBrowser, creating a new
> ServiceResolver, creating a new RecordBrowser and so on) without
> ever having any problem.
>
>
> ----- Mail original -----
> De: "Danny Smit" <danny.smit.0 at gmail.com>
> À: avahi at lists.freedesktop.org
> Envoyé: Mardi 23 Décembre 2014 16:22:29
> Objet: [avahi] Race condition using the avahi D-Bus interface?
>
> Hi everyone,
>
> I'm running into a problem with avahi which looks similar to the
> following reported issue: http://avahi.org/ticket/247
>
> However in this case I'm using c++ / Qt to connect to the avahi
> daemon. This basically exists out of two steps:
>
> 1. Create a ServiceBrowser using the D-Bus API ServiceBrowserNew
> 2. Connect to the ItemNew signal of the created ServiceBrowser
>
> It seems that at step 1 the browser immediately start resolving
> services and that it may occur that the ItemNew signal is emitted even
> before step 2 is finished. The way the avahi ServiceBrowser is
> designed, there is no way to influence this. From my point of view it
> looks like this design is prone to race conditions.
>
> My question is, how is this supposed to work? Should I use the avahi
> interface differently? Or is this a bug in the design of the avahi
> ServiceBrowser D-Bus interface?
>
> Any help would be greatly appreciated.
>
> Kind regards,
>
> Danny
> _______________________________________________
> avahi mailing list
> avahi at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/avahi
> _______________________________________________
> avahi mailing list
> avahi at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/avahi


More information about the avahi mailing list