summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@sun.com>2010-05-21 17:17:01 +0400
committerAlexander Nozdrin <alik@sun.com>2010-05-21 17:17:01 +0400
commit75e552d50910e88debeca2fa18cc6d9a18da1843 (patch)
treecee7c59ceb75b7c60315f06eaa747756fbebeb97 /vio
parent534b3a520b0796c85bde36b2790d0e2c62184c1f (diff)
downloadmariadb-git-75e552d50910e88debeca2fa18cc6d9a18da1843.tar.gz
Fix for Bug#52923 (Inadequate documentation of "Can't get hostname for your address" error).
The thing is that on some platforms (e.g. Mac OS X) sockaddr_in / sockaddr_in6 contain a non-standard field (sin_len / sin6_len), that must be set. The problem was that only standard fields were set, thus getnameinfo() returned EAI_SYSTEM instead of EAI_NONAME. The fix is to introduce configure-time checks (for GNU auto-tools and CMake) for those additional fields and to set them if they are available.
Diffstat (limited to 'vio')
-rw-r--r--vio/viosocket.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 6c361e4a462..9c0243db4f3 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -1057,9 +1057,11 @@ ssize_t vio_pending(Vio *vio)
/**
This is a wrapper for the system getnameinfo(), because different OS
- differ in the getnameinfo() implementation. For instance, Solaris 10
- requires that the 2nd argument (salen) must match the actual size of the
- struct sockaddr_storage passed to it.
+ differ in the getnameinfo() implementation:
+ - Solaris 10 requires that the 2nd argument (salen) must match the
+ actual size of the struct sockaddr_storage passed to it;
+ - Mac OS X has sockaddr_in::sin_len and sockaddr_in6::sin6_len and
+ requires them to be filled.
*/
int vio_getnameinfo(const struct sockaddr *sa,
@@ -1072,11 +1074,17 @@ int vio_getnameinfo(const struct sockaddr *sa,
switch (sa->sa_family) {
case AF_INET:
sa_length= sizeof (struct sockaddr_in);
+#ifdef HAVE_SOCKADDR_IN_SIN_LEN
+ ((struct sockaddr_in *) sa)->sin_len= sa_length;
+#endif /* HAVE_SOCKADDR_IN_SIN_LEN */
break;
#ifdef HAVE_IPV6
case AF_INET6:
sa_length= sizeof (struct sockaddr_in6);
+# ifdef HAVE_SOCKADDR_IN6_SIN6_LEN
+ ((struct sockaddr_in6 *) sa)->sin6_len= sa_length;
+# endif /* HAVE_SOCKADDR_IN6_SIN6_LEN */
break;
#endif /* HAVE_IPV6 */
}