[libdmapsharing] Attempt to serve on IPv6 Signed-off-by: W. Michael Petullo <mike flyn org>



commit 3b32c4360cd46b3f4653306c3e9a1522b249121b
Author: W. Michael Petullo <mike flyn org>
Date:   Tue Jan 4 11:22:21 2011 -0600

    Attempt to serve on IPv6
    Signed-off-by: W. Michael Petullo <mike flyn org>

 libdmapsharing/dmap-share.c |   32 ++++++++++++++++++++++++++------
 tests/dpapview.vala         |    2 +-
 2 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/libdmapsharing/dmap-share.c b/libdmapsharing/dmap-share.c
index 998cf0a..6b898b6 100644
--- a/libdmapsharing/dmap-share.c
+++ b/libdmapsharing/dmap-share.c
@@ -241,18 +241,38 @@ static void ctrl_int_adapter (SoupServer *server,
 gboolean
 _dmap_share_server_start (DMAPShare *share)
 {
+	SoupAddress *addr;
 	guint port = DMAP_SHARE_GET_CLASS (share)->get_desired_port (share);
 	gboolean              password_required;
 
-	share->priv->server = soup_server_new (SOUP_SERVER_PORT, port, NULL);
+	addr = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV6, port);
+	share->priv->server = soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
+	g_object_unref (addr);
+
 	if (share->priv->server == NULL) {
 		g_warning ("Unable to start music sharing server on port %d, trying any open port", port);
-		share->priv->server = soup_server_new (SOUP_SERVER_PORT, SOUP_ADDRESS_ANY_PORT, NULL);
+		addr = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV6, SOUP_ADDRESS_ANY_PORT);
+		share->priv->server = soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
+		g_object_unref (addr);
+	}
 
-		if (share->priv->server == NULL) {
-			g_warning ("Unable to start music sharing server");
-			return FALSE;
-		}
+	if (share->priv->server == NULL) {
+		g_warning ("Unable to start music sharing server, trying IPv4 only");
+		addr = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV4, port);
+		share->priv->server = soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
+		g_object_unref (addr);
+	}
+
+	if (share->priv->server == NULL) {
+		g_warning ("Unable to start music sharing server on port %d, trying IPv4 only, any open port", port);
+		addr = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV4, SOUP_ADDRESS_ANY_PORT);
+		share->priv->server = soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
+		g_object_unref (addr);
+	}
+
+	if (share->priv->server == NULL) {
+		g_warning ("Unable to start music sharing server");
+		return FALSE;
 	}
 
 	share->priv->port = (guint)soup_server_get_port (share->priv->server);
diff --git a/tests/dpapview.vala b/tests/dpapview.vala
index eb1e3b6..57b4586 100644
--- a/tests/dpapview.vala
+++ b/tests/dpapview.vala
@@ -36,8 +36,8 @@ private class DPAPViewer {
 				string path;
 				int fd = GLib.FileUtils.open_tmp ("dpapview.XXXXXX", out path);
 				GLib.FileUtils.set_contents (path, (string) ((ValaDPAPRecord) v).thumbnail, ((ValaDPAPRecord) v).filesize);
-				pixbuf = new Gdk.Pixbuf.from_file (path);
 				GLib.FileUtils.close (fd);
+				pixbuf = new Gdk.Pixbuf.from_file (path);
 				GLib.FileUtils.unlink (path);
 			}
 



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