[PATCH app/xhost 4/4] On Win32, don't use SIGALRM to timeout gethostaddr(), just wait

Jon TURNEY jon.turney at dronecode.org.uk
Fri Feb 15 08:08:40 PST 2013


Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 xhost.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/xhost.c b/xhost.c
index aa1dbec..1739d8f 100644
--- a/xhost.c
+++ b/xhost.c
@@ -727,6 +727,7 @@ get_hostname(XHostAddress *ha)
 	   gethostbyaddr will continue after a signal, so we have to
 	   jump out of it. 
 	   */
+#ifdef SIGALRM
 #ifndef X_NOT_POSIX
 	memset(&sa, 0, sizeof sa);
 	sa.sa_handler = nameserver_lost;
@@ -736,6 +737,8 @@ get_hostname(XHostAddress *ha)
 	signal(SIGALRM, nameserver_lost);
 #endif
 	alarm(NAMESERVER_TIMEOUT);
+#endif
+
 #ifdef X_NOT_POSIX
 	if (setjmp(env) == 0) 
 #endif
@@ -743,7 +746,9 @@ get_hostname(XHostAddress *ha)
 	    getnameinfo((struct sockaddr *) &saddr, saddrlen, inetname,
 	      sizeof(inetname), NULL, 0, 0);
 	}
+#ifdef SIGALRM
 	alarm(0);
+#endif
 	if (nameserver_timedout || inetname[0] == '\0')
 	    inet_ntop(((struct sockaddr *)&saddr)->sa_family, ha->address,
 		inetname, sizeof(inetname));
@@ -763,6 +768,7 @@ get_hostname(XHostAddress *ha)
 	   gethostbyaddr will continue after a signal, so we have to
 	   jump out of it. 
 	   */
+#ifdef SIGALRM
 #ifndef X_NOT_POSIX
 	memset(&sa, 0, sizeof sa);
 	sa.sa_handler = nameserver_lost;
@@ -772,6 +778,8 @@ get_hostname(XHostAddress *ha)
 	signal(SIGALRM, nameserver_lost);
 #endif
 	alarm(4);
+#endif
+
 #ifdef X_NOT_POSIX
 	if (setjmp(env) == 0) {
 #endif
@@ -779,7 +787,9 @@ get_hostname(XHostAddress *ha)
 #ifdef X_NOT_POSIX
 	}
 #endif
+#ifdef SIGALRM
 	alarm(0);
+#endif
 	if (hp)
 	    return (hp->h_name);
 	else return (inet_ntoa(*((struct in_addr *)(ha->address))));
-- 
1.7.9



More information about the xorg-devel mailing list