summaryrefslogtreecommitdiff
path: root/sql/hostname.cc
diff options
context:
space:
mode:
authoreric@mysql.com <>2005-09-02 17:07:05 -0700
committereric@mysql.com <>2005-09-02 17:07:05 -0700
commit5a8af4cb9eb2a345477982f353df02d625f48d78 (patch)
treef886358fd80ae2ce919dffb869ac2225cd66d9a4 /sql/hostname.cc
parent9dc0da7c4656726b7a56980e3e28a299557a9462 (diff)
downloadmariadb-git-5a8af4cb9eb2a345477982f353df02d625f48d78.tar.gz
Backport of JimW's localhost patch to 4.1 tree.
Handle systems like default FC4 where 127.0.0.1 doesn't always map to 'localhost' first. (Bug #11822)
Diffstat (limited to 'sql/hostname.cc')
-rw-r--r--sql/hostname.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/hostname.cc b/sql/hostname.cc
index 39223556024..32e1d84fac3 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -130,15 +130,23 @@ void reset_host_errors(struct in_addr *in)
VOID(pthread_mutex_unlock(&hostname_cache->lock));
}
+/* Deal with systems that don't defined INADDR_LOOPBACK */
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK 0x7f000001UL
+#endif
my_string ip_to_hostname(struct in_addr *in, uint *errors)
{
uint i;
host_entry *entry;
DBUG_ENTER("ip_to_hostname");
+ *errors= 0;
+
+ /* We always treat the loopback address as "localhost". */
+ if (in->s_addr == htonl(INADDR_LOOPBACK))
+ DBUG_RETURN((char *)my_localhost);
/* Check first if we have name in cache */
- *errors=0;
if (!(specialflag & SPECIAL_NO_HOST_CACHE))
{
VOID(pthread_mutex_lock(&hostname_cache->lock));