[avahi] Making a client robust

Lennart Poettering lennart at poettering.net
Fri Sep 5 01:57:30 PDT 2008


On Fri, 05.09.08 08:00, Julien PUYDT (julien.puydt at laposte.net) wrote:

> 
> Lennart Poettering a écrit :
> > The only error code I'd catch to restart things is
> > AVAHI_CLIENT_FAILURE with avahi_client_errno() ==
> > AVAHI_ERR_DISCONNECTED. That is usually caused by avahi daemon
> > restarts. The correct way to handle that is described in the doxygen docs:
> > 
> > http://avahi.org/download/doxygen/main.html
> > 
> > (The part about "How to Write a Client That Can Deal with Daemon
> > Restarts")
> > 
> > The other errors are mostly non recoverable. i.e. argument errors and
> > similar kind that won't go away by repeating those calls.
> 
> What the above link doesn't document well -- hence my failure (see 
> recent postings) -- is : how does one *update* the data once published?

This is documented: 

"When you need to modify your services (i.e. change the TXT data or
the port number), use the AVAHI_PUBLISH_UPDATE flag. Please do not
free the entry group and create a new one. This would inhibit some
traffic limiting algorithms in mDNS. When changing just the TXT data
avahi_entry_group_update_txt() is a shortcut for
AVAHI_PUBLISH_UPDATE. Please note that you cannot use
AVAHI_PUBLISH_UPDATE when changing the service name! Renaming a DNS-SD
service is identical to deleting and creating a new one, and that's
exactly what you should do in that case. First call
avahi_entry_group_reset() to remove it and then read it normally."

Or in other words:

a) if you rename a service or any other entry group member, just reset
   the entry group and readd all members. The example shipped with
   Avahi shows this:

   http://avahi.org/download/doxygen/client-publish-service_8c-example.html

   (see modify_callback() and related code)

b) if you just change the meta data attached to a service but leave
   the name unmodified you should not reset the entry group but simply
   add the entries to your group again, but pass AVAHI_PUBLISH_UPDATE
   in the flags field.

Hope this helps.

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4


More information about the avahi mailing list