List:Internals« Previous MessageNext Message »
From:monty Date:May 16 2002 1:32pm
Subject:bk commit into 3.23 tree
View as plain text  
Below is the list of changes that have just been commited into a local
3.23. repository of monty. When monty does a push, they will be
propogaged to the main repository and within 24 hours after the push into
the public repository. For information on how to access
the public repository see
http://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.1027 02/05/16 16:32:51 monty@stripped +13 -0
  New my_gethostbyname_r() handling
  Changed some status variable names
  Fix bug in GRANT ... PASSWORD string

  mysys/my_gethostbyname.c
    1.1 02/05/16 16:32:49 monty@stripped +119 -0

  sql/sql_acl.cc
    1.34 02/05/16 16:32:49 monty@stripped +9 -4
    Fix bug in GRANT ... PASSWORD string

  sql/mysqld.cc
    1.237 02/05/16 16:32:49 monty@stripped +2 -2
    change some status variable names

  sql/mini_client.cc
    1.25 02/05/16 16:32:49 monty@stripped +2 -13
    New my_gethostbyname_r() handling

  sql/hostname.cc
    1.14 02/05/16 16:32:49 monty@stripped +6 -1
    New my_gethostbyname_r() handling

  mysys/my_thr_init.c
    1.12 02/05/16 16:32:49 monty@stripped +9 -0
    New my_gethostbyname_r() handling

  mysys/my_pthread.c
    1.15 02/05/16 16:32:49 monty@stripped +0 -54
    New my_gethostbyname_r() handling

  mysys/my_gethostbyname.c
    1.0 02/05/16 16:32:49 monty@stripped +0 -0
    BitKeeper file /my/bk/mysql/mysys/my_gethostbyname.c

  mysys/Makefile.am
    1.23 02/05/16 16:32:49 monty@stripped +1 -1
    New my_gethostbyname_r() handling

  libmysql/libmysql.c
    1.69 02/05/16 16:32:49 monty@stripped +2 -13
    New my_gethostbyname_r() handling

  libmysql/Makefile.shared
    1.13 02/05/16 16:32:49 monty@stripped +1 -1
    New my_gethostbyname_r() handling

  include/my_pthread.h
    1.42 02/05/16 16:32:49 monty@stripped +0 -25
    New my_gethostbyname_r() handling

  include/my_net.h
    1.7 02/05/16 16:32:49 monty@stripped +36 -0
    New my_gethostbyname_r() handling

  Docs/manual.texi
    1.789 02/05/16 16:32:49 monty@stripped +16 -7
    Update of variable names

# 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:	monty
# Host:	hundin.mysql.fi
# Root:	/my/bk/mysql

--- 1.788/Docs/manual.texi	Wed May 15 01:01:24 2002
+++ 1.789/Docs/manual.texi	Thu May 16 16:32:49 2002
@@ -19678,17 +19678,17 @@
 @item @code{Open_files} @tab  Number of files that are open.
 @item @code{Open_streams} @tab Number of streams that are open (used mainly for logging).
 @item @code{Opened_tables} @tab Number of tables that have been opened.
-@item @code{Select_full_join} @tab Number of joins without keys (Should be 0).
+@item @code{Select_full_join} @tab Number of joins without keys (If this is 0, you should carefully check the index of your tables).
 @item @code{Select_full_range_join} @tab Number of joins where we used a range search on reference table.
 @item @code{Select_range} @tab Number of joins where we used ranges on the first table. (It's normally not critical even if this is big.)
-@item @code{Select_scan} @tab Number of joins where we scanned the first table.
-@item @code{Select_range_check} @tab Number of joins without keys where we check for key usage after each row (Should be 0).
+@item @code{Select_scan} @tab Number of joins where we did a full scann of the first table.
+@item @code{Select_range_check} @tab Number of joins without keys where we check for key usage after each row (If this is 0, you should carefully check the index of your tables).
 @item @code{Questions} @tab Number of queries sent to the server.
 @item @code{Slave_open_temp_tables} @tab Number of temporary tables currently
 open by the slave thread
-@item @code{Slow_launch_threads} @tab Number of threads that have taken more than @code{slow_launch_time} to connect.
+@item @code{Slow_launch_threads} @tab Number of threads that have taken more than @code{slow_launch_time} to create.
 @item @code{Slow_queries} @tab Number of queries that have taken more than @code{long_query_time}. @xref{Slow query log}.
-@item @code{Sort_merge_passes} @tab Number of merges the sort has to do. If this value is large you should consider increasing @code{sort_buffer}.
+@item @code{Sort_merge_passes} @tab Number of merges passes the sort algoritm have had to do. If this value is large you should consider increasing @code{sort_buffer}.
 @item @code{Sort_range} @tab Number of sorts that where done with ranges.
 @item @code{Sort_rows}  @tab Number of sorted rows.
 @item @code{Sort_scan}  @tab Number of sorts that where done by scanning the table.
@@ -19712,8 +19712,8 @@
 If @code{Opened_tables} is big, then your @code{table_cache}
 variable is probably too small.
 @item
-If @code{key_reads} is big, then your @code{key_cache} is probably too
-small.  The cache hit rate can be calculated with
+If @code{key_reads} is big, then your @code{key_buffer_size} variable is
+probably too small.  The cache hit rate can be calculated with
 @code{key_reads}/@code{key_read_requests}.
 @item
 If @code{Handler_read_rnd} is big, then you probably have a lot of
@@ -46915,6 +46915,15 @@
 @node News-3.23.51, News-3.23.50, News-3.23.x, News-3.23.x
 @appendixsubsec Changes in release 3.23.51
 @itemize @bullet
+@item
+Changed name of variables @code{Com_show_master_stat} to
+@code{Com_show_master_status} and @code{Com_show_slave_stat} to
+@code{Com_show_slave_status}.
+@item
+Changed handling of @code{gethostbyname()} to make the client library
+threadsafe even if @code{gethostbyname_r} doesn't exists.
+@item
+Fixed core-dump problem when giving a wrong password string to @code{GRANT}.
 @item
 Fixed bug in @code{DROP DATABASE} with symlinked directory.
 @item

--- 1.6/include/my_net.h	Fri Feb  2 03:47:05 2001
+++ 1.7/include/my_net.h	Thu May 16 16:32:49 2002
@@ -36,6 +36,42 @@
 
 void my_inet_ntoa(struct in_addr in, char *buf);
 
+/*
+  Handling of gethostbyname_r()
+*/
+
+#if defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
+#if !defined(HPUX)
+struct hostent;
+#endif /* HPUX */
+struct hostent *my_gethostbyname_r(const char *name,
+				   struct hostent *result, char *buffer,
+				   int buflen, int *h_errnop);
+#define my_gethostbyname_r_free()
+#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
+#define GETHOSTBYNAME_BUFF_SIZE 2048
+#else
+#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
+#endif /* defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
+
+#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
+#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
+struct hostent *my_gethostbyname_r(const char *name,
+				   struct hostent *result, char *buffer,
+				   int buflen, int *h_errnop);
+#define my_gethostbyname_r_free()
+#elif !defined(HAVE_GETHOSTBYNAME_R)
+#define GETHOSTBYNAME_BUFF_SIZE 2048
+struct hostent *my_gethostbyname_r(const char *name,
+				   struct hostent *result, char *buffer,
+				   int buflen, int *h_errnop);
+void my_gethostbyname_r_free();
+#else
+#define GETHOSTBYNAME_BUFF_SIZE 2048
+#define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
+#define my_gethostbyname_r_free()
+#endif /* defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
+
 #ifdef	__cplusplus
 }
 #endif

--- 1.41/include/my_pthread.h	Tue Apr 16 21:18:15 2002
+++ 1.42/include/my_pthread.h	Thu May 16 16:32:49 2002
@@ -426,31 +426,6 @@
 #define HAVE_PTHREAD_KILL
 #endif
 
-#if defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
-#if !defined(HPUX)
-struct hostent;
-#endif /* HPUX */
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop);
-#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
-#define GETHOSTBYNAME_BUFF_SIZE 2048
-#else
-#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
-#endif /* defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
-
-#else
-#ifdef HAVE_GETHOSTBYNAME_R_RETURN_INT
-#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop);
-#else
-#define GETHOSTBYNAME_BUFF_SIZE 2048
-#define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
-#endif /* HAVE_GETHOSTBYNAME_R_RETURN_INT */
-#endif /* defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
-
 #endif /* defined(__WIN__) */
 
 	/* safe_mutex adds checking to mutex for easier debugging */

--- 1.68/libmysql/libmysql.c	Thu Apr 18 18:24:08 2002
+++ 1.69/libmysql/libmysql.c	Thu May 16 16:32:49 2002
@@ -1312,7 +1312,6 @@
       memcpy_fixed(&sock_addr.sin_addr,&ip_addr,sizeof(ip_addr));
     }
     else
-#if defined(HAVE_GETHOSTBYNAME_R) && defined(_REENTRANT) && defined(THREAD)
     {
       int tmp_errno;
       struct hostent tmp_hostent,*hp;
@@ -1323,22 +1322,12 @@
       {
 	net->last_errno=CR_UNKNOWN_HOST;
 	sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, tmp_errno);
+	my_gethostbyname_r_free();
 	goto error;
       }
       memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
+      my_gethostbyname_r_free();
     }
-#else
-    {
-      struct hostent *hp;
-      if (!(hp=gethostbyname(host)))
-      {
-	net->last_errno=CR_UNKNOWN_HOST;
-	sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, socket_errno);
-	goto error;
-      }
-      memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
-    }
-#endif
     sock_addr.sin_port = (ushort) htons((ushort) port);
     if (connect2(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
 		 mysql->options.connect_timeout) <0)

--- 1.22/mysys/Makefile.am	Thu Feb  7 21:34:34 2002
+++ 1.23/mysys/Makefile.am	Thu May 16 16:32:49 2002
@@ -46,7 +46,7 @@
 			my_quick.c my_lockmem.c my_static.c \
 			getopt.c getopt1.c getvar.c my_mkdir.c \
 			default.c my_compress.c checksum.c raid.cc my_net.c \
-			my_vsnprintf.c charset.c my_bitmap.c
+			my_vsnprintf.c charset.c my_bitmap.c my_gethostbyname.c
 EXTRA_DIST =		thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
 			thr_mutex.c thr_rwlock.c
 libmysys_a_LIBADD =	@THREAD_LOBJECTS@

--- 1.14/mysys/my_pthread.c	Tue Apr 16 21:18:15 2002
+++ 1.15/mysys/my_pthread.c	Thu May 16 16:32:49 2002
@@ -23,9 +23,6 @@
 #include <m_string.h>
 #include <thr_alarm.h>
 #include <assert.h>
-#if !defined(MSDOS) && !defined(__WIN__)
-#include <netdb.h>
-#endif
 
 #if (defined(__BSD__) || defined(_BSDI_VERSION)) && !defined(HAVE_mit_thread)
 #define SCHED_POLICY SCHED_RR
@@ -423,57 +420,6 @@
   return error == EAGAIN ? ETIMEDOUT : error;
 }
 #endif /* HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT */
-
-/*
-  Emulate SOLARIS style calls, not because it's better, but just to make the
-  usage of getbostbyname_r simpler.
-*/
-
-#if !defined(my_gethostbyname_r) && defined(HAVE_GETHOSTBYNAME_R)
-
-#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
-
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop)
-{
-  struct hostent *hp;
-  dbug_assert((size_t) buflen >= sizeof(*result));
-  if (gethostbyname_r(name,result, buffer, (size_t) buflen, &hp, h_errnop))
-    return 0;
-  return hp;
-}
-
-#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
-
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop)
-{
-  dbug_assert(buflen >= sizeof(struct hostent_data));
-  if (gethostbyname_r(name,result,(struct hostent_data *) buffer) == -1)
-  {
-    *h_errnop= errno;
-    return 0;
-  }
-  return result;
-}
-
-#else
-
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop)
-{
-  struct hostent *hp;
-  dbug_assert(buflen >= sizeof(struct hostent_data));
-  hp= gethostbyname_r(name,result,(struct hostent_data *) buffer);
-  *h_errnop= errno;
-  return hp;
-}
-
-#endif /* GLIBC2_STYLE_GETHOSTBYNAME_R */
-#endif
 
 
 /* Some help functions */

--- 1.11/mysys/my_thr_init.c	Wed Aug 22 01:45:04 2001
+++ 1.12/mysys/my_thr_init.c	Thu May 16 16:32:49 2002
@@ -35,6 +35,9 @@
 #ifndef HAVE_LOCALTIME_R
 pthread_mutex_t LOCK_localtime_r;
 #endif
+#ifndef HAVE_GETHOSTBYNAME_R
+pthread_mutex_t LOCK_gethostbyname_r;
+#endif
 #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
 pthread_mutexattr_t my_fast_mutexattr;
 #endif
@@ -78,6 +81,9 @@
 #ifndef HAVE_LOCALTIME_R
   pthread_mutex_init(&LOCK_localtime_r,MY_MUTEX_INIT_SLOW);
 #endif
+#ifndef HAVE_GETHOSTBYNAME_R
+  pthread_mutex_init(&LOCK_gethostbyname_r,MY_MUTEX_INIT_SLOW);
+#endif
   return my_thread_init();
 }
 
@@ -91,6 +97,9 @@
 #endif
 #ifdef PPTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
   pthread_mutexattr_destroy(&my_errchk_mutexattr);
+#endif
+#ifndef HAVE_GETHOSTBYNAME_R
+  pthread_mutex_destroy(&LOCK_gethostbyname_r);
 #endif
 }
 

--- 1.13/sql/hostname.cc	Wed Aug 22 01:45:04 2001
+++ 1.14/sql/hostname.cc	Thu May 16 16:32:49 2002
@@ -171,17 +171,22 @@
   {
     DBUG_PRINT("error",("gethostbyname_r returned %d",tmp_errno));
     add_wrong_ip(in);
+    my_gethostbyname_r_free();
     DBUG_RETURN(0);
   }
   if (!hp->h_name[0])
   {
     DBUG_PRINT("error",("Got an empty hostname"));
     add_wrong_ip(in);
+    my_gethostbyname_r_free();
     DBUG_RETURN(0);				// Don't allow empty hostnames
   }
   if (!(name=my_strdup(hp->h_name,MYF(0))))
+  {
+    my_gethostbyname_r_free();
     DBUG_RETURN(0);				// out of memory
-
+  }
+  my_gethostbyname_r_free();
 #else
   VOID(pthread_mutex_lock(&LOCK_hostname));
   if (!(hp=gethostbyaddr((char*) in,sizeof(*in), AF_INET)))

--- 1.24/sql/mini_client.cc	Wed Sep 12 23:53:30 2001
+++ 1.25/sql/mini_client.cc	Thu May 16 16:32:49 2002
@@ -614,7 +614,6 @@
       memcpy_fixed(&sock_addr.sin_addr,&ip_addr,sizeof(ip_addr));
     }
     else
-#if defined(HAVE_GETHOSTBYNAME_R) && defined(_REENTRANT) && defined(THREAD)
     {
       int tmp_errno;
       struct hostent tmp_hostent,*hp;
@@ -625,22 +624,12 @@
       {
 	net->last_errno=CR_UNKNOWN_HOST;
 	sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, tmp_errno);
+	my_gethostbyname_r_free();
 	goto error;
       }
       memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
+      my_gethostbyname_r_free();
     }
-#else
-    {
-      struct hostent *hp;
-      if (!(hp=gethostbyname(host)))
-      {
-	net->last_errno=CR_UNKNOWN_HOST;
-	sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, socket_errno);
-	goto error;
-      }
-      memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
-    }
-#endif
     sock_addr.sin_port = (ushort) htons((ushort) port);
     if (mc_sock_connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
 			mysql->options.connect_timeout) <0)

--- 1.236/sql/mysqld.cc	Wed Apr 17 11:45:15 2002
+++ 1.237/sql/mysqld.cc	Thu May 16 16:32:49 2002
@@ -3149,10 +3149,10 @@
   {"Com_show_grants",	       (char*) (com_stat+(uint) SQLCOM_SHOW_GRANTS),SHOW_LONG},
   {"Com_show_keys",	       (char*) (com_stat+(uint) SQLCOM_SHOW_KEYS),SHOW_LONG},
   {"Com_show_logs",	       (char*) (com_stat+(uint) SQLCOM_SHOW_LOGS),SHOW_LONG},
-  {"Com_show_master_stat",     (char*) (com_stat+(uint) SQLCOM_SHOW_MASTER_STAT),SHOW_LONG},
+  {"Com_show_master_status",   (char*) (com_stat+(uint) SQLCOM_SHOW_MASTER_STAT),SHOW_LONG},
   {"Com_show_open_tables",     (char*) (com_stat+(uint) SQLCOM_SHOW_OPEN_TABLES),SHOW_LONG},
   {"Com_show_processlist",     (char*) (com_stat+(uint) SQLCOM_SHOW_PROCESSLIST),SHOW_LONG},
-  {"Com_show_slave_stat",      (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_STAT),SHOW_LONG},
+  {"Com_show_slave_status",    (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_STAT),SHOW_LONG},
   {"Com_show_status",	       (char*) (com_stat+(uint) SQLCOM_SHOW_STATUS),SHOW_LONG},
   {"Com_show_tables",	       (char*) (com_stat+(uint) SQLCOM_SHOW_TABLES),SHOW_LONG},
   {"Com_show_variables",       (char*) (com_stat+(uint) SQLCOM_SHOW_VARIABLES),SHOW_LONG},

--- 1.33/sql/sql_acl.cc	Mon May 13 05:00:23 2002
+++ 1.34/sql/sql_acl.cc	Thu May 16 16:32:49 2002
@@ -983,12 +983,17 @@
   char *password,empty_string[1];
   DBUG_ENTER("replace_user_table");
 
+  password=empty_string;
+  empty_string[0]=0;
+
   if (combo.password.str && combo.password.str[0])
-    password=combo.password.str;
-  else
   {
-    password=empty_string;
-    empty_string[0]=0;
+    if (combo.password.length != HASH_PASSWORD_LENGTH)
+    {
+      my_error(ER_PASSWORD_NO_MATCH,MYF(0));
+      DBUG_RETURN(-1);
+    }
+    password=combo.password.str;
   }
 
   table->field[0]->store(combo.host.str,combo.host.length);
--- New file ---
+++ mysys/my_gethostbyname.c	02/05/16 16:32:49
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
   
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.
   
   You should have received a copy of the GNU Library General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
   MA 02111-1307, USA */

/* Thread safe version of gethostbyname_r() */

#include "mysys_priv.h"
#include "my_pthread.h"
#include <assert.h>
#include <my_net.h>
#if !defined(MSDOS) && !defined(__WIN__)
#include <netdb.h>
#endif

/* This file is not needed if my_gethostbyname_r is a macro */
#if !defined(my_gethostbyname_r)

#ifndef THREAD
#define pthread_mutex_lock(A)
#define pthread_mutex_unlock(A)
#endif

/*
  Emulate SOLARIS style calls, not because it's better, but just to make the
  usage of getbostbyname_r simpler.
*/

#if defined(HAVE_GETHOSTBYNAME_R)

#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)

struct hostent *my_gethostbyname_r(const char *name,
				   struct hostent *result, char *buffer,
				   int buflen, int *h_errnop)
{
  struct hostent *hp;
  dbug_assert((size_t) buflen >= sizeof(*result));
  if (gethostbyname_r(name,result, buffer, (size_t) buflen, &hp, h_errnop))
    return 0;
  return hp;
}

#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)

struct hostent *my_gethostbyname_r(const char *name,
				   struct hostent *result, char *buffer,
				   int buflen, int *h_errnop)
{
  dbug_assert(buflen >= sizeof(struct hostent_data));
  if (gethostbyname_r(name,result,(struct hostent_data *) buffer) == -1)
  {
    *h_errnop= errno;
    return 0;
  }
  return result;
}

#else

/* gethostbyname_r with similar interface as gethostbyname() */

struct hostent *my_gethostbyname_r(const char *name,
				   struct hostent *result, char *buffer,
				   int buflen, int *h_errnop)
{
  struct hostent *hp;
  dbug_assert(buflen >= sizeof(struct hostent_data));
  hp= gethostbyname_r(name,result,(struct hostent_data *) buffer);
  *h_errnop= errno;
  return hp;
}
#endif /* GLIBC2_STYLE_GETHOSTBYNAME_R */

#else /* !HAVE_GETHOSTBYNAME_R */

#ifdef THREAD
extern pthread_mutex_t LOCK_gethostbyname_r;
#endif

/*
  No gethostbyname_r() function exists.
  In this case we have to keep a mutex over the call to ensure that no
  other thread is going to reuse the internal memory.

  The user is responsible to call my_gethostbyname_r_free() when he
  is finished with the structure.
*/

struct hostent *my_gethostbyname_r(const char *name,
				   struct hostent *result, char *buffer,
				   int buflen, int *h_errnop)
{
  struct hostent *hp;
  pthread_mutex_lock(&LOCK_gethostbyname_r);
  hp= gethostbyname(name);
  *h_errnop= h_errno;
  return hp;
}

void my_gethostbyname_r_free()
{
  pthread_mutex_unlock(&LOCK_gethostbyname_r);  
}

#endif /* !HAVE_GETHOSTBYNAME_R */
#endif /* !my_gethostbyname_r */


--- 1.12/libmysql/Makefile.shared	Fri Aug 10 03:16:42 2001
+++ 1.13/libmysql/Makefile.shared	Thu May 16 16:32:49 2002
@@ -56,7 +56,7 @@
 			thr_mutex.lo mulalloc.lo string.lo default.lo \
 			my_compress.lo array.lo my_once.lo list.lo my_net.lo \
                         charset.lo hash.lo mf_iocache.lo my_seek.lo \
-			my_pread.lo mf_cache.lo
+			my_pread.lo mf_cache.lo my_gethostbyname.lo
 # Not needed in the minimum library
 mysysobjects2 =		getopt.lo getopt1.lo getvar.lo my_lib.lo
 mysysobjects =		$(mysysobjects1) $(mysysobjects2)
Thread
bk commit into 3.23 treemonty16 May