]> git.meshlink.io Git - catta/commitdiff
add new client state AVAHI_CLIENT_FAILURE
authorLennart Poettering <lennart@poettering.net>
Sun, 6 Nov 2005 15:00:43 +0000 (15:00 +0000)
committerLennart Poettering <lennart@poettering.net>
Sun, 6 Nov 2005 15:00:43 +0000 (15:00 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@931 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-client/client.c
avahi-client/client.h
avahi-common/gccmacro.h
avahi-compat-howl/compat.c
avahi-compat-libdns_sd/compat.c
avahi-utils/avahi-browse.c
examples/client-publish-service.c

index ce4cfa0df4eb03d38e46b687198cd89e484fba82..d4faed039ffbe551a017610a92bcc8012b84047a 100644 (file)
@@ -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);
index 5128bd9ddb16df8da3fbfee27fa96cae8d50aaa1..36bf7cdddaefba8278bdfac464a310e841b16f40 100644 (file)
@@ -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 */
index 2e427b7a2f9d79f83312b2f7fa9dc174ea6164e2..78a09a73fd99208d20e8adb057b6e380407f6d90 100644 (file)
 
 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
index 18171f8504c8b1695a2421f1bfc4f4bcc6454be7..8db8fe0233b33edad01ae0539390871c68015821 100644 (file)
@@ -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;
index 70ccd4b1ef3141b08508a6ad027851e01956fab4..6fec3c96b40ee8bcfbc406bf478426f5af5d83cc 100644 (file)
@@ -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;
index 169f62bd7c8d778c939d90263a6eb5d9413559eb..b8910fcb720981266e66023a609b9d395bd789ca 100644 (file)
@@ -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);
index 7013156fd5cbdc3e25a781de18b281a796feb880..2f126c173090e33b5d9dde77658e28b48f3bcd04 100644 (file)
@@ -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:
             ;
     }