summaryrefslogtreecommitdiff
path: root/xhost.c
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2012-10-26 14:48:03 +0100
committerJon TURNEY <jon.turney@dronecode.org.uk>2013-03-02 14:36:01 +0000
commit214c90d6b01017fe02675e133129cf389e740533 (patch)
treefcfa0b7bb881133d11f9ff2c20f0d0313d7d870f /xhost.c
parent19250c1aed852e151bf66819e75f8d796018223b (diff)
If SIGALRM isn't available, don't use alarm() to timeout gethostaddr(), just wait
Win32 has neither SIGALRM nor sigaction(), so don't use SIGALRM to timeout gethostaddr(), just wait Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Diffstat (limited to 'xhost.c')
-rw-r--r--xhost.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/xhost.c b/xhost.c
index a5edc08..fd13dae 100644
--- a/xhost.c
+++ b/xhost.c
@@ -653,7 +653,9 @@ get_hostname(XHostAddress *ha)
char *kname;
static char kname_out[255];
#endif
+#ifdef SIGALRM
struct sigaction sa;
+#endif
#ifdef TCPCONN
#if defined(IPv6) && defined(AF_INET6)
@@ -690,14 +692,18 @@ get_hostname(XHostAddress *ha)
gethostbyaddr will continue after a signal, so we have to
jump out of it.
*/
+#ifdef SIGALRM
memset(&sa, 0, sizeof sa);
sa.sa_handler = nameserver_lost;
sa.sa_flags = 0; /* don't restart syscalls */
sigaction(SIGALRM, &sa, NULL);
alarm(NAMESERVER_TIMEOUT);
+#endif
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));
@@ -711,13 +717,17 @@ get_hostname(XHostAddress *ha)
gethostbyaddr will continue after a signal, so we have to
jump out of it.
*/
+#ifdef SIGALRM
memset(&sa, 0, sizeof sa);
sa.sa_handler = nameserver_lost;
sa.sa_flags = 0; /* don't restart syscalls */
sigaction(SIGALRM, &sa, NULL);
alarm(4);
+#endif
hp = gethostbyaddr (ha->address, ha->length, AF_INET);
+#ifdef SIGALRM
alarm(0);
+#endif
if (hp)
return (hp->h_name);
else return (inet_ntoa(*((struct in_addr *)(ha->address))));