From 1ed7dbec53aec2cd9f7fb4afbb48abf199b2e01b Mon Sep 17 00:00:00 2001 From: Koichiro IWAO Date: Tue, 23 Feb 2016 15:14:22 +0900 Subject: [PATCH] common: add log for g_tcp_connect in case getaddrinfo(3) might fail. In FreeBSD, AI_V4MAPPED support for getaddrinfo(3) was very recently implemented[1]. Most of FreeBSD systems in the world do not have this implementation yet. This will be a problem when AI_V4MAPPED isn't supported and xrdp is built with IPv6 option. In such a case, g_tcp_connect always fails. Of course getaddrinfo(3) might fail in other cases. The log helps us to know what's happening. [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198092 --- common/os_calls.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/os_calls.c b/common/os_calls.c index a4c98a75..f02b8c65 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -668,6 +668,7 @@ int APP_CC g_tcp_connect(int sck, const char *address, const char *port) { int res = 0; + char errorMsg[256]; struct addrinfo p; struct addrinfo *h = (struct addrinfo *)NULL; struct addrinfo *rp = (struct addrinfo *)NULL; @@ -693,6 +694,12 @@ g_tcp_connect(int sck, const char *address, const char *port) { res = getaddrinfo(address, port, &p, &h); } + if (res != 0) + { + snprintf(errorMsg, 255, "g_tcp_connect: getaddrinfo() failed: %s", + gai_strerror(res)); + log_message(LOG_LEVEL_ERROR, errorMsg); + } if (res > -1) { if (h != NULL)