List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:July 19 2005 12:00am
Subject:bk commit into 5.0 tree (jimw:1.1946) BUG#11822
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1946 05/07/18 17:00:37 jimw@stripped +2 -0
  Handle systems where 127.0.0.1 doesn't always map to 'localhost'
  first. (Bug #11822)

  sql/sql_parse.cc
    1.448 05/07/18 17:00:33 jimw@stripped +10 -20
    Push special handling of 127.0.0.1 into ip_to_hostname().

  sql/hostname.cc
    1.30 05/07/18 17:00:33 jimw@stripped +9 -1
    Short-circuit ip_to_hostname() lookup for INADDR_LOOPBACK to
    always return 'localhost'.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-11822

--- 1.29/sql/hostname.cc	2005-05-13 04:04:27 -07:00
+++ 1.30/sql/hostname.cc	2005-07-18 17:00:33 -07:00
@@ -130,15 +130,23 @@
   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 == INADDR_LOOPBACK)
+    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));

--- 1.447/sql/sql_parse.cc	2005-07-18 08:36:16 -07:00
+++ 1.448/sql/sql_parse.cc	2005-07-18 17:00:33 -07:00
@@ -775,29 +775,19 @@
       return (ER_OUT_OF_RESOURCES);
     thd->host_or_ip= thd->ip;
     vio_in_addr(net->vio,&thd->remote.sin_addr);
-#if !defined(HAVE_SYS_UN_H) || defined(HAVE_mit_thread)
-    /* Fast local hostname resolve for Win32 */
-    if (!strcmp(thd->ip,"127.0.0.1"))
+    if (!(specialflag & SPECIAL_NO_RESOLVE))
     {
-      thd->host= (char*) my_localhost;
-      thd->host_or_ip= my_localhost;
-    }
-    else
-#endif
-    {
-      if (!(specialflag & SPECIAL_NO_RESOLVE))
+      vio_in_addr(net->vio,&thd->remote.sin_addr);
+      thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors);
+      /* Cut very long hostnames to avoid possible overflows */
+      if (thd->host)
       {
-	vio_in_addr(net->vio,&thd->remote.sin_addr);
-	thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors);
-	/* Cut very long hostnames to avoid possible overflows */
-	if (thd->host)
-	{
-	  thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0;
-	  thd->host_or_ip= thd->host;
-	}
-	if (connect_errors > max_connect_errors)
-	  return(ER_HOST_IS_BLOCKED);
+        if (thd->host != my_localhost)
+          thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0;
+        thd->host_or_ip= thd->host;
       }
+      if (connect_errors > max_connect_errors)
+        return(ER_HOST_IS_BLOCKED);
     }
     DBUG_PRINT("info",("Host: %s  ip: %s",
 		       thd->host ? thd->host : "unknown host",
Thread
bk commit into 5.0 tree (jimw:1.1946) BUG#11822Jim Winstead19 Jul