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
ulab-next-nosound
Koichiro IWAO 9 years ago
parent f100036cd9
commit 1ed7dbec53

@ -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)

Loading…
Cancel
Save