summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2000-10-28 23:26:48 -0600
committerunknown <sasha@mysql.sashanet.com>2000-10-28 23:26:48 -0600
commit3dfc0a825ed3961460eb17b814fabab900adbffb (patch)
treed6984a4bdab21e43bace50514dc6578eafcae414 /sql
parentb0f645e4657abffc86e357fc334113af9e7cd380 (diff)
downloadmariadb-git-3dfc0a825ed3961460eb17b814fabab900adbffb.tar.gz
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 BitKeeper/etc/ignore: Added .gdb_history to the ignore list 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
Diffstat (limited to 'sql')
-rw-r--r--sql/mini_client.cc1
-rw-r--r--sql/mysqld.cc15
-rw-r--r--sql/slave.cc10
-rw-r--r--sql/sql_string.h2
4 files changed, 24 insertions, 4 deletions
diff --git a/sql/mini_client.cc b/sql/mini_client.cc
index 6ba2de57d2d..34f5c0a6ccd 100644
--- a/sql/mini_client.cc
+++ b/sql/mini_client.cc
@@ -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;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d366c3bd999..ede8f0e14a7 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -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;
diff --git a/sql/slave.cc b/sql/slave.cc
index 6873933dfd3..018aed585ac 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -273,7 +273,10 @@ int fetch_nx_table(THD* thd, MASTER_INFO* mi)
error = 0;
err:
if(mysql)
- mc_mysql_close(mysql);
+ {
+ mc_mysql_close(mysql);
+ mysql = 0;
+ }
if(nx_errno && thd->net.vio)
send_error(&thd->net, nx_errno, "Error in fetch_nx_table");
@@ -942,7 +945,10 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused)))
err:
thd->query = thd->db = 0; // extra safety
if(mysql)
- mc_mysql_close(mysql);
+ {
+ mc_mysql_close(mysql);
+ mysql = 0;
+ }
thd->proc_info = "waiting for slave mutex on exit";
pthread_mutex_lock(&LOCK_slave);
slave_running = 0;
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 45c82b82dd0..1c9e822cce5 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -125,7 +125,7 @@ public:
char *new_ptr;
if (!(new_ptr=(char*) my_realloc(Ptr,arg_length,MYF(0))))
{
- (void) my_free(Ptr,MYF(0));
+ Alloced_length = 0;
real_alloc(arg_length);
}
else