]> git.meshlink.io Git - catta/commitdiff
fix logic of AVAHI_SERVER_REGISTERING state handling. Many clients assumed that
authorLennart Poettering <lennart@poettering.net>
Tue, 22 Aug 2006 01:48:13 +0000 (01:48 +0000)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 Aug 2006 01:48:13 +0000 (01:48 +0000)
this state would follow only on a AVAHI_SERVER_COLLISION state. However, this
is not true, hence we need to handle this state transition, too. Mostly the
same as we already handle AVAHI_SERVER_COLLISION.

git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1258 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-compat-howl/compat.c
avahi-compat-libdns_sd/compat.c
avahi-utils/avahi-publish.c
examples/client-publish-service.c
examples/core-publish-service.c

index a7e280905781373061e439498f647f7674e2e526..e4362081ca5a8740e0e1a9d3595493001ebcaa34 100644 (file)
@@ -711,13 +711,13 @@ static void reg_client_callback(oid_data *data, AvahiClientState state) {
         }
             
         case AVAHI_CLIENT_S_COLLISION:
+        case AVAHI_CLIENT_S_REGISTERING:
 
             /* Remove our entry */
             avahi_entry_group_reset(data->object);
             break;
 
         case AVAHI_CLIENT_CONNECTING:
-        case AVAHI_CLIENT_S_REGISTERING:
             /* Ignore */
             break;
     }
index b4f2fc6f3762529c5a2b18e8fea218ff42156faf..e5692bbe7f66db406e3765791398547b7dded42d 100644 (file)
@@ -897,6 +897,7 @@ static void reg_client_callback(AvahiClient *s, AvahiClientState state, void* us
         }
             
         case AVAHI_CLIENT_S_COLLISION:
+        case AVAHI_CLIENT_S_REGISTERING:
 
             /* Remove our entry */
             avahi_entry_group_reset(sdref->entry_group);
@@ -904,7 +905,6 @@ static void reg_client_callback(AvahiClient *s, AvahiClientState state, void* us
             break;
 
         case AVAHI_CLIENT_CONNECTING:
-        case AVAHI_CLIENT_S_REGISTERING:
             /* Ignore */
             break;
     }
index 9ca2df21a38db473adc73aec9a729a3caf580851..77dc42276bb2f038630c4b4e8d1df64c59091b23 100644 (file)
@@ -189,7 +189,11 @@ static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UN
 
             if (config->verbose)
                 fprintf(stderr, "Host name conflict\n");
+
+            /* Fall through */
             
+        case AVAHI_CLIENT_S_REGISTERING:
+
             if (entry_group) {
                 avahi_entry_group_free(entry_group);
                 entry_group = NULL;
@@ -200,9 +204,9 @@ static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UN
             
             if (config->verbose)
                 fprintf(stderr, "Waiting for daemon ...\n");
+            
             break;
             
-        case AVAHI_CLIENT_S_REGISTERING:
             ;
     }
 }
index 96afaf33810de89827143126ffbb4b8073395931..66a59de04fc803a27758e80110f275e9dfadf80e 100644 (file)
@@ -71,6 +71,8 @@ static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state,
 
         case AVAHI_ENTRY_GROUP_FAILURE :
 
+            fprintf(stderr, "Entry group failure: %s\n", avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))));
+
             /* Some kind of failure happened while we were registering our services */
             avahi_simple_poll_quit(simple_poll);
             break;
@@ -142,24 +144,32 @@ static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UN
                 create_services(c);
             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_COLLISION:
         
             /* Let's drop our registered services. When the server is back
              * in AVAHI_SERVER_RUNNING state we will register them
              * again with the new host name. */
-            if (group)
-                avahi_entry_group_reset(group);
-            break;
             
-        case AVAHI_CLIENT_FAILURE:
+        case AVAHI_CLIENT_S_REGISTERING:
+
+            /* The server records are now being established. This
+             * might be caused by a host name change. We need to wait
+             * for our own records to register until the host name is
+             * properly esatblished. */
             
-            fprintf(stderr, "Client failure: %s\n", avahi_strerror(avahi_client_errno(c)));
-            avahi_simple_poll_quit(simple_poll);
+            if (group)
+                avahi_entry_group_reset(group);
             
             break;
 
         case AVAHI_CLIENT_CONNECTING:
-        case AVAHI_CLIENT_S_REGISTERING:
             ;
     }
 }
index 65dfe5d84e74cf60cafb80f59d7b65ba90bf6858..6370383488462bdee0f1d848ccaced33cde72e02 100644 (file)
@@ -72,6 +72,8 @@ static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntry
             
         case AVAHI_ENTRY_GROUP_FAILURE :
 
+            fprintf(stderr, "Entry group failure: %s\n", avahi_strerror(avahi_server_errno(s)));
+            
             /* Some kind of failure happened while we were registering our services */
             avahi_simple_poll_quit(simple_poll);
             break;
@@ -162,14 +164,19 @@ static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UN
                 return;
             }
 
-            /* Let's drop our registered services. When the server is back
+        }
+
+            /* Fall through */
+
+        case AVAHI_SERVER_REGISTERING:
+            
+           /* Let's drop our registered services. When the server is back
              * in AVAHI_SERVER_RUNNING state we will register them
              * again with the new host name. */
             if (group)
                 avahi_s_entry_group_reset(group);
 
             break;
-        }
 
         case AVAHI_SERVER_FAILURE:
             
@@ -180,7 +187,6 @@ static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UN
             break;
 
         case AVAHI_SERVER_INVALID:
-        case AVAHI_SERVER_REGISTERING:
             ;
     }
 }