Re: Moving to bonjour over howl

On Fri, 16.09.05 17:17, Alexander Larsson (alexl redhat com) wrote:

> I'm not saying Avahi needs a mainloop. However, GServiceBrowser clearly
> needs one. Anyway, I was just explaining why the gnome-vfs dns-sd code
> looks like it does. It seemed like David just looked at it and said
> "ewww, this is ugly, I'll do my own thing instead" without an
> understanding of why it looks like it does.

Mmmh, I share Davyd's opinion on the current gnome-vfs. Your
"pseudo-synchronous approach" (i.e. start browsing, wait 100ms, stop
browsing, and take the returned entries as current list of available
services) for browsing for services if kind of broken im my eyes. Even
if you do it because you need a synchronous wrapper around an
asynchronous API. 

But I guess this discussion doesn't belong here.

> > Avahi doesn't use any threading/locking primitives itself. However,
> > this doesn't mean it isn't thread safe. As long as you use Avahi from
> > a single thread at the same time only it is perfectly legal to use it
> > in a multi-threaded environment. In fact the avahi-sharp bindings use
> > Avahi that way. A minimal event loop is run in its own thread and
> > the little locking needed is done entirely with C# locking
> > primitives. 
> Then it might be hard to use Avahi for gnome-vfs. Gnome-vfs is threaded,
> in that asynchronous i/o operations are run in worker threads. These
> worker threads might need to do dns-sd calls when reading e.g.
> network:///. gnome-vfs itself can lock around calls to the dns-sd engine
> so that use of it from gnome-vfs is serialized. However, what if the app
> using gnome-vfs also uses Avahi itself? Is it possible to instantiate a
> separate context of Avahi? That would make this possible.

Yes, absolutely. Avahi doesn't maintain any global state. You can have
as many seperate connections to the daemon as you wish. The
connections don't interfere with each other in any way.

If fact you can even run multiple avahi *stacks* in the same process
side-by-side. Would be kind of stupid, but is perfectly legal.

Avahi was designed to be usable in multi-threaded environments. 

The only global variable Avahi maintains is a vtable for plugging in
different malloc() implementations.


Lennart Poettering; lennart [at] poettering [dot] de
ICQ# 11060553; GPG 0x1A015CC4;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]