Commit 96815f82 authored by sasha@mysql.sashanet.com's avatar sasha@mysql.sashanet.com
Browse files

libmysql/libmysql.c

    keep vio from being freed twice when we are low on memory
mysys/safemalloc.c
    changes for --safemalloc-mem-limit
sql/mini_client.cc
    keep vio from being freed twice
sql/mysqld.cc
    changes for --safemalloc-mem-limit
sql/slave.cc
    prevent closing connection twice
sql/sql_string.h
    shrink() did not work right when my_realloc() failed
parent efeec3f2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -163,3 +163,4 @@ include/.my_sys.h.swp
PENDING/2000-10-25.01
PENDING/2000-10-25.02
support-files/mysql-3.23.27-beta.spec
.gdb_history
+1 −0
Original line number Diff line number Diff line
@@ -1333,6 +1333,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
  if (!net->vio || my_net_init(net, net->vio))
  {
    vio_delete(net->vio);
    net->vio = 0;
    net->last_errno=CR_OUT_OF_MEMORY;
    strmov(net->last_error,ER(net->last_errno));
    goto error;
+13 −2
Original line number Diff line number Diff line
@@ -73,6 +73,10 @@
#include "my_static.h"
#include "mysys_err.h"

#ifndef DBUG_OFF
ulonglong safemalloc_mem_limit = 0;
#endif

#define pNext		tInt._pNext
#define pPrev		tInt._pPrev
#define sFileName	tInt._sFileName
@@ -125,9 +129,16 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
    DBUG_ENTER("_mymalloc");
    DBUG_PRINT("enter",("Size: %u",uSize));


    if (!sf_malloc_quick)
      (void) _sanity (sFile, uLine);

#ifndef DBUG_OFF    
    if(safemalloc_mem_limit &&
       uSize + lCurMemory > safemalloc_mem_limit)
      pTmp = 0;
    else
#endif      
       /* Allocate the physical memory */
       pTmp = (struct remember *) malloc (
		sizeof (struct irem)			/* remember data  */
+1 −0
Original line number Diff line number Diff line
@@ -611,6 +611,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
  if (!net->vio || my_net_init(net, net->vio))
  {
    vio_delete(net->vio);
    net->vio = 0; // safety
    net->last_errno=CR_OUT_OF_MEMORY;
    strmov(net->last_error,ER(net->last_errno));
    goto error;
+14 −1
Original line number Diff line number Diff line
@@ -248,6 +248,10 @@ double log_10[32]; /* 10 potences */
I_List<THD> threads,thread_cache;
time_t start_time;

#if !defined(DBUG_OFF) && defined(SAFEMALLOC)
extern ulonglong safemalloc_mem_limit;
#endif

pthread_key(MEM_ROOT*,THR_MALLOC);
pthread_key(THD*, THR_THD);
pthread_key(NET*, THR_NET);
@@ -2228,7 +2232,7 @@ enum options {
               OPT_BINLOG_IGNORE_DB,     OPT_WANT_CORE,
	       OPT_SKIP_CONCURRENT_INSERT, OPT_MEMLOCK, OPT_MYISAM_RECOVER,
	       OPT_REPLICATE_REWRITE_DB, OPT_SERVER_ID, OPT_SKIP_SLAVE_START,
	       OPT_SKIP_INNOBASE
	       OPT_SKIP_INNOBASE,OPT_SAFEMALLOC_MEM_LIMIT
};

static struct option long_options[] = {
@@ -2284,6 +2288,10 @@ static struct option long_options[] = {
  {"master-info-file",      required_argument, 0, (int) OPT_MASTER_INFO_FILE},
  {"myisam-recover",	    optional_argument, 0, (int) OPT_MYISAM_RECOVER},
  {"memlock",		    no_argument,       0, (int) OPT_MEMLOCK},
#if !defined(DBUG_OFF) && defined(SAFEMALLOC)
  {"safemalloc-mem-limit",  required_argument, 0, (int)
     OPT_SAFEMALLOC_MEM_LIMIT},
#endif    
  {"new",                   no_argument,       0, 'n'},
  {"old-protocol",          no_argument,       0, 'o'},
#ifdef ONE_THREAD
@@ -2797,6 +2805,11 @@ static void get_options(int argc,char **argv)
    case 'P':
      mysql_port= (unsigned int) atoi(optarg);
      break;
#if !defined(DBUG_OFF) && defined(SAFEMALLOC)      
    case OPT_SAFEMALLOC_MEM_LIMIT:
      safemalloc_mem_limit = atoi(optarg);
      break;
#endif      
    case OPT_SOCKET:
      mysql_unix_port= optarg;
      break;
Loading