[seahorse-sharing] Reconnect to Avahi when it restarts.



commit 7aac003db334113059601216d6c399cdb0822035
Author: Stef Walter <stefw collabora co uk>
Date:   Sat Sep 24 11:16:53 2011 +0200

    Reconnect to Avahi when it restarts.

 daemon/seahorse-sharing.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/daemon/seahorse-sharing.c b/daemon/seahorse-sharing.c
index 08d5cbf..0372038 100644
--- a/daemon/seahorse-sharing.c
+++ b/daemon/seahorse-sharing.c
@@ -36,6 +36,8 @@
 
 #define HKP_SERVICE_TYPE "_pgpkey-hkp._tcp."
 
+static gboolean    start_publishing        (void);
+
 /**
  * SECTION:seahorse-sharing
  * @short_description: Starts the HKP service and offers it using Avahi
@@ -273,6 +275,8 @@ static void
 client_callback (AvahiClient *client, AvahiClientState state,
                  AVAHI_GCC_UNUSED void * userdata)
 {
+	gboolean errmsg;
+
 	g_assert (!avahi_client || client == avahi_client);
 
 	switch (state) {
@@ -299,9 +303,15 @@ client_callback (AvahiClient *client, AvahiClientState state,
 		break;
 
 	case AVAHI_CLIENT_FAILURE:
-		g_warning ("failure talking with avahi: %s",
-		           avahi_strerror (avahi_client_errno (client)));
-		stop_publishing (TRUE);
+		errmsg = (avahi_client_errno (client) != AVAHI_ERR_DISCONNECTED);
+		if (errmsg)
+			g_warning ("failure talking with avahi: %s",
+			           avahi_strerror (avahi_client_errno (client)));
+		stop_publishing (errmsg);
+
+		/* Try to restart */
+		sleep (1);
+		start_publishing ();
 		break;
 
 	default:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]