From 6f37f0e1126ad3776b80dbd64701f38a58738921 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 6 Nov 2005 15:00:43 +0000 Subject: [PATCH 1/1] add new client state AVAHI_CLIENT_FAILURE git-svn-id: file:///home/lennart/svn/public/avahi/trunk@931 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-client/client.c | 1 + avahi-client/client.h | 9 +++++---- avahi-common/gccmacro.h | 8 ++------ avahi-compat-howl/compat.c | 1 + avahi-compat-libdns_sd/compat.c | 4 +++- avahi-utils/avahi-browse.c | 7 ++++++- examples/client-publish-service.c | 7 +++++++ 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/avahi-client/client.c b/avahi-client/client.c index ce4cfa0..d4faed0 100644 --- a/avahi-client/client.c +++ b/avahi-client/client.c @@ -62,6 +62,7 @@ static void client_set_state (AvahiClient *client, AvahiServerState state) { switch (client->state) { case AVAHI_CLIENT_DISCONNECTED: + case AVAHI_CLIENT_FAILURE: if (client->bus) { dbus_connection_disconnect(client->bus); dbus_connection_unref(client->bus); diff --git a/avahi-client/client.h b/avahi-client/client.h index 5128bd9..36bf7cd 100644 --- a/avahi-client/client.h +++ b/avahi-client/client.h @@ -43,10 +43,11 @@ typedef struct AvahiClient AvahiClient; /** States of a client object, a superset of AvahiServerState */ typedef enum { - AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING, - AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, - AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, - AVAHI_CLIENT_DISCONNECTED = 100 /**< Lost DBUS connection to the Avahi daemon */ + AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING, /**< Server state: REGISTERING */ + AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, /**< Server state: RUNNING */ + AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, /**< Server state: COLLISION */ + AVAHI_CLIENT_DISCONNECTED = 100, /**< Lost DBUS connection to the Avahi daemon */ + AVAHI_CLIENT_FAILURE = 101 /**< Some kind of error happened on the client side */ } AvahiClientState; /** The function prototype for the callback of an AvahiClient */ diff --git a/avahi-common/gccmacro.h b/avahi-common/gccmacro.h index 2e427b7..78a09a7 100644 --- a/avahi-common/gccmacro.h +++ b/avahi-common/gccmacro.h @@ -28,13 +28,9 @@ AVAHI_C_DECL_BEGIN -#ifdef __GNUC__ -#if __GNUC__ >= 4 +#if defined(__GNUC__) && (__GNUC__ >= 4) #define AVAHI_GCC_SENTINEL __attribute__ ((sentinel)) -#endif -#endif - -#ifndef AVAHI_GCC_SENTINEL +#else /** Macro for usage of GCC's sentinel compilation warnings */ #define AVAHI_GCC_SENTINEL #endif diff --git a/avahi-compat-howl/compat.c b/avahi-compat-howl/compat.c index 18171f8..8db8fe0 100644 --- a/avahi-compat-howl/compat.c +++ b/avahi-compat-howl/compat.c @@ -694,6 +694,7 @@ static void reg_client_callback(oid_data *data, AvahiClientState state) { return; switch (state) { + case AVAHI_CLIENT_FAILURE: case AVAHI_CLIENT_DISCONNECTED: reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID); break; diff --git a/avahi-compat-libdns_sd/compat.c b/avahi-compat-libdns_sd/compat.c index 70ccd4b..6fec3c9 100644 --- a/avahi-compat-libdns_sd/compat.c +++ b/avahi-compat-libdns_sd/compat.c @@ -479,7 +479,8 @@ static void generic_client_callback(AvahiClient *s, AvahiClientState state, void assert(sdref->n_ref >= 1); switch (state) { - + + case AVAHI_CLIENT_FAILURE: case AVAHI_CLIENT_DISCONNECTED: if (sdref->service_browser_callback) @@ -860,6 +861,7 @@ static void reg_client_callback(AvahiClient *s, AvahiClientState state, void* us return; switch (state) { + case AVAHI_CLIENT_FAILURE: case AVAHI_CLIENT_DISCONNECTED: reg_report_error(sdref, kDNSServiceErr_Unknown); break; diff --git a/avahi-utils/avahi-browse.c b/avahi-utils/avahi-browse.c index 169f62b..b8910fc 100644 --- a/avahi-utils/avahi-browse.c +++ b/avahi-utils/avahi-browse.c @@ -473,8 +473,13 @@ static void browse_domains(Config *c) { n_all_for_now++; } -static void client_callback(AVAHI_GCC_UNUSED AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { +static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { switch (state) { + case AVAHI_CLIENT_FAILURE: + fprintf(stderr, "Client failure, exiting: %s\n", avahi_strerror(avahi_client_errno(c))); + avahi_simple_poll_quit(simple_poll); + break; + case AVAHI_CLIENT_DISCONNECTED: fprintf(stderr, "Client disconnected, exiting.\n"); avahi_simple_poll_quit(simple_poll); diff --git a/examples/client-publish-service.c b/examples/client-publish-service.c index 7013156..2f126c1 100644 --- a/examples/client-publish-service.c +++ b/examples/client-publish-service.c @@ -157,6 +157,13 @@ static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UN break; + case AVAHI_CLIENT_FAILURE: + + fprintf(stderr, "Client failure: %s\n", avahi_strerror(avahi_client_errno(c))); + avahi_simple_poll_quit(simple_poll); + + break; + case AVAHI_CLIENT_S_REGISTERING: ; } -- 2.39.2