[evolution-data-server/camel-socks-proxy-master] Try all the struct addrinfo when connecting to a proxy, not just the first one



commit fabe6304e1d3808861a11b2621eb030959b63c73
Author: Federico Mena Quintero <federico novell com>
Date:   Thu Jul 22 15:20:21 2010 -0500

    Try all the struct addrinfo when connecting to a proxy, not just the first one
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 camel/camel-tcp-stream-raw.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index e1594ec..1317a12 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -620,7 +620,7 @@ out:
 static PRFileDesc *
 connect_to_proxy (CamelTcpStreamRaw *raw, const gchar *proxy_host, gint proxy_port, GError **error)
 {
-	struct addrinfo *ai, hints;
+	struct addrinfo *addr, *ai, hints;
 	gchar serv[16];
 	PRFileDesc *fd;
 	gint save_errno;
@@ -634,16 +634,25 @@ connect_to_proxy (CamelTcpStreamRaw *raw, const gchar *proxy_host, gint proxy_po
 	memset (&hints, 0, sizeof (hints));
 	hints.ai_socktype = SOCK_STREAM;
 
-	ai = camel_getaddrinfo (proxy_host, serv, &hints, error);
-	if (!ai)
+	addr = camel_getaddrinfo (proxy_host, serv, &hints, error);
+	if (!addr)
 		return NULL;
 
 	d (g_print ("  creating socket and connecting\n"));
 
-	fd = socket_connect (ai, error);
+	ai = addr;
+	while (ai) {
+		fd = socket_connect (ai, error);
+		if (fd)
+			goto out;
+
+		ai = ai->ai_next;
+	}
+
+out:
 	save_errno = errno;
 
-	camel_freeaddrinfo (ai);
+	camel_freeaddrinfo (addr);
 
 	if (!fd) {
 		errno = save_errno;



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