[evolution-patches] if getaddrinfo() fails, set an exception



It seems that gentoo systems are broken (hold surprise) in that they
don't list "imap" in /etc/services and so gentoo suers have been getting
silent host lookup failures when using at least imap.

the attached patch will at least make it so that an exception dialog
pops up, tho we may also want to change the use of the
camel_getaddrinfo() code to use hard coded port numebrs rather than
service names? Dunno.

(Note: an earlier camel-services.c patch is included in this diff, but
since it was only a 1-line change figured it wouldn't be any trouble to
ignore)

Jeff

-- 
Jeffrey Stedfast
Evolution Hacker - Novell, Inc.
fejj ximian com  - www.novell.com
? 67028.patch
? camel-tls.patch
? getaddrinfo-ex.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2251.2.12
diff -u -r1.2251.2.12 ChangeLog
--- ChangeLog	29 Sep 2004 01:57:11 -0000	1.2251.2.12
+++ ChangeLog	4 Oct 2004 19:44:00 -0000
@@ -1,3 +1,12 @@
+2004-10-04  Jeffrey Stedfast  <fejj novell com>
+
+	* camel-service.c (camel_getaddrinfo): Add a non-const cast for
+	hints when changing the ai_family member in the IPv6-disabled
+	case. Fixes bug #67028.
+	(cs_waitinfo): Set an exception if reply->result != 0. Also fixed
+	the "cannot create thread" case (was missing a printf-style
+	argument to setv).
+
 2004-09-28  Not Zed  <NotZed Ximian com>
 
 	** See bug #66509.
Index: camel-service.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-service.c,v
retrieving revision 1.90.14.1
diff -u -r1.90.14.1 camel-service.c
--- camel-service.c	23 Sep 2004 04:12:29 -0000	1.90.14.1
+++ camel-service.c	4 Oct 2004 19:44:01 -0000
@@ -31,7 +31,11 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
 #include <pthread.h>
+#include <netdb.h>
 #include <errno.h>
 
 #include <sys/poll.h>
@@ -737,9 +741,31 @@
 			d(printf("waiting for child to exit\n"));
 			pthread_join(id, NULL);
 			d(printf("child done\n"));
+			
+			if (reply->result != 0) {
+				const char *hostaddr;
+				char ntopbuf[50];
+				
+				if (reply->name) {
+					hostaddr = reply->name;
+				} else if (reply->addr->sa_family == AF_INET) {
+					hostaddr = inet_ntop (AF_INET, &((struct sockaddr_in *) reply->addr)->sin_addr,
+							      ntopbuf, sizeof (ntopbuf));
+#ifdef ENABLE_IPv6
+				} else if (reply->addr->sa_family == AF_INET6) {
+					hostaddr = inet_ntop (AF_INET6, &((struct sockaddr_in6 *) reply->addr)->sin6_addr,
+							      ntopbuf, sizeof (ntopbuf));
+#endif /* ENABLE_Ipv6 */
+				} else {
+					hostaddr = "unknown address";
+				}
+				
+				camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s: %s", error,
+						      hostaddr, gai_strerror (reply->result));
+			}
 		}
 	} else {
-		camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s: %s", _("cannot create thread"), g_strerror(err));
+		camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s: %s", error, _("cannot create thread"), g_strerror(err));
 	}
 	e_msgport_destroy(reply_port);
 
@@ -897,7 +923,7 @@
 		hints = &myhints;
 	}
 
-	hints->ai_family = AF_INET;
+	((struct addrinfo *) hints)->ai_family = AF_INET;
 #endif
 
 	msg = g_malloc0(sizeof(*msg));

Attachment: smime.p7s
Description: S/MIME cryptographic signature



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