List:Commits« Previous MessageNext Message »
From:John David Duncan Date:November 7 2011 2:07am
Subject:bzr push into mysql-5.5-cluster branch (john.duncan:3625 to 3626)
View as plain text  
 3626 John David Duncan	2011-11-06
      Fix for memory leaks in Record and in Config_v1 configuration reader.

    modified:
      storage/ndb/memcache/include/Record.h
      storage/ndb/memcache/include/TableSpec.h
      storage/ndb/memcache/src/Config_v1.cc
      storage/ndb/memcache/src/Record.cc
      storage/ndb/memcache/src/TableSpec.cc
 3625 jonas oreland	2011-11-03
      ndb - new content in ndbinfo gives new line numbers

    modified:
      mysql-test/suite/perfschema/r/pfs_upgrade.result
=== modified file 'storage/ndb/memcache/include/Record.h'
--- a/storage/ndb/memcache/include/Record.h	2011-09-29 19:13:43 +0000
+++ b/storage/ndb/memcache/include/Record.h	2011-11-07 02:05:20 +0000
@@ -83,7 +83,7 @@ class Record {
   /* Public instance variables */
   const int ncolumns;
   size_t rec_size;
-  const NdbRecord *ndb_record; 
+  NdbRecord *ndb_record; 
   int nkeys;
   int nvalues;
   
@@ -96,6 +96,7 @@ class Record {
   size_t size_of_nullmap;
   DataTypeHandler ** const handlers;
   NdbDictionary::RecordSpecification * const specs;
+  NdbDictionary::Dictionary * m_dict;
   
   /* Private methods */
   const Record & operator=(const Record &) const;

=== modified file 'storage/ndb/memcache/include/TableSpec.h'
--- a/storage/ndb/memcache/include/TableSpec.h	2011-09-22 18:27:10 +0000
+++ b/storage/ndb/memcache/include/TableSpec.h	2011-11-07 02:05:20 +0000
@@ -103,6 +103,8 @@ inline TableSpec::TableSpec(const char *
 inline void TableSpec::setTable(const char *db, const char *table) {
   schema_name = db;
   table_name = table;
+  must_free.schema_name = 1;
+  must_free.table_name  = 1;
 }
 
 

=== modified file 'storage/ndb/memcache/src/Config_v1.cc'
--- a/storage/ndb/memcache/src/Config_v1.cc	2011-09-30 07:03:26 +0000
+++ b/storage/ndb/memcache/src/Config_v1.cc	2011-11-07 02:05:20 +0000
@@ -429,7 +429,10 @@ TableSpec * config_v1::get_container_rec
     /* Instantiate a TableSpec for this container */
     container = new TableSpec(0, keycols, valcols);
     container->setTable(schema, table);
-    
+
+    if(keycols) free(keycols);
+    if(valcols) free(valcols);
+        
     //  `flags` VARCHAR(250) NOT NULL DEFAULT "0",
     /* If the value is non-numeric, use it to set the flags_column field */
     container->flags_column = 0;
@@ -659,7 +662,8 @@ void config_v1::log_signon() {
   op.writeTuple(tx);
   tx->execute(NdbTransaction::Commit);
   tx->getGCI(&signon_gci);
-  
+
+  tx->close();  
   free(op.key_buffer);
   free(op.buffer);
   return;
@@ -742,7 +746,8 @@ int server_roles_reload_waiter(Ndb_clust
   db.init(4);
   NdbDictionary::Dictionary *dict = db.getDictionary();
 
-  if(dict->getEvent(event_name) == 0) {
+  const NdbDictionary::Event * stored_event = dict->getEvent(event_name);
+  if(stored_event == 0) {
     if(create_event(dict, event_name) != 0) {
       return -1;
     }

=== modified file 'storage/ndb/memcache/src/Record.cc'
--- a/storage/ndb/memcache/src/Record.cc	2011-10-01 01:01:07 +0000
+++ b/storage/ndb/memcache/src/Record.cc	2011-11-07 02:05:20 +0000
@@ -38,6 +38,7 @@ Record::Record(int ncol) : ncolumns(ncol
 {};
 
 Record::~Record() {
+  m_dict->releaseRecord(ndb_record);
   delete[] handlers;
   delete[] specs;
 };
@@ -129,6 +130,7 @@ void Record::build_null_bitmap() {
 bool Record::complete(NdbDictionary::Dictionary *dict, 
                       const NdbDictionary::Table *table) {
   build_null_bitmap();
+  m_dict = dict;
   ndb_record = dict->createRecord(table, specs, ncolumns, sizeof(specs[0]));
 
   if(!ndb_record) {
@@ -144,6 +146,7 @@ bool Record::complete(NdbDictionary::Dic
 bool Record::complete(NdbDictionary::Dictionary *dict, 
                       const NdbDictionary::Index *ndb_index) {                       
   build_null_bitmap();
+  m_dict = dict;
   ndb_record = dict->createRecord(ndb_index, specs, ncolumns, sizeof(specs[0]));
 
   if(!ndb_record) {

=== modified file 'storage/ndb/memcache/src/TableSpec.cc'
--- a/storage/ndb/memcache/src/TableSpec.cc	2011-10-14 08:26:28 +0000
+++ b/storage/ndb/memcache/src/TableSpec.cc	2011-11-07 02:05:20 +0000
@@ -85,8 +85,10 @@ TableSpec::TableSpec(const char *sqltabl
 {
   nkeycols = build_column_list(key_columns, keycols);
   if(nkeycols) must_free.first_key = 1;
+  
   nvaluecols = build_column_list(value_columns, valcols);
-  must_free.first_val = (nvaluecols);
+  if(nvaluecols) must_free.first_val = 1;
+  
   if(sqltable) {
     char *sqltabname = strdup(sqltable);
     schema_name = sqltabname;
@@ -98,6 +100,7 @@ TableSpec::TableSpec(const char *sqltabl
       *s = '\0' ;
       table_name = s+1;
     }
+    must_free.none = 0;
     must_free.table_name = must_free.all_val_cols = must_free.special_cols = 0;
   }
 }
@@ -134,14 +137,17 @@ TableSpec::~TableSpec() {
   if(! must_free.none) {
     if(must_free.schema_name && schema_name) free((void *) schema_name);
     if(must_free.table_name && table_name) free((void *) table_name);
+
     if(must_free.first_key)  free((void *) key_columns[0]);
     else if(must_free.all_key_cols)
       for(int i = 0 ; i < nkeycols ; i++)
         free((void *) key_columns[i]);
+
     if(must_free.first_val) free((void *) value_columns[0]);
     else if(must_free.all_val_cols)
       for(int i = 0 ; i < nvaluecols ; i++) 
         free((void *) value_columns[i]);
+
     if(must_free.special_cols) {
       if(flags_column) free((void *) flags_column);
       if(math_column)  free((void *) math_column);

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster branch (john.duncan:3625 to 3626) John David Duncan7 Nov