- if (state == AVAHI_SERVER_RUNNING)
- /* The serve has startup successfully and registered its host
- * name on the network, so it's time to create our services */
- create_services(s);
-
- else if (state == AVAHI_SERVER_COLLISION) {
- char *n;
- int r;
-
- /* A host name collision happened. Let's pick a new name for the server */
- n = avahi_alternative_host_name(avahi_server_get_host_name(s));
- fprintf(stderr, "Host name collision, retrying with '%s'\n", n);
- r = avahi_server_set_host_name(s, n);
- avahi_free(n);
-
- if (r < 0) {
- fprintf(stderr, "Failed to set new host name: %s\n", avahi_strerror(r));
+ switch (state) {
+
+ case AVAHI_SERVER_RUNNING:
+ /* The serve has startup successfully and registered its host
+ * name on the network, so it's time to create our services */
+
+ if (!group)
+ create_services(s);
+
+ break;
+
+ case AVAHI_SERVER_COLLISION: {
+ char *n;
+ int r;
+
+ /* A host name collision happened. Let's pick a new name for the server */
+ n = avahi_alternative_host_name(avahi_server_get_host_name(s));
+ fprintf(stderr, "Host name collision, retrying with '%s'\n", n);
+ r = avahi_server_set_host_name(s, n);
+ avahi_free(n);
+
+ if (r < 0) {
+ fprintf(stderr, "Failed to set new host name: %s\n", avahi_strerror(r));
+
+ avahi_simple_poll_quit(simple_poll);
+ return;
+ }