Commit 638fe9ec authored by unknown's avatar unknown
Browse files

misc (memleak) fixes:

    added using ndb_end and showing mem allocation stat at exit
    added init of variable
    added destruction of LocalConfig to still memleak
    added delete of theFacade on exit
    stopSessions(true) on socket server to ensure destuction of threads
    added destruction of arbit manager thread
    added true option to stopSessions in transporter facade to ensure destructions of threads


ndb/include/util/ndb_opts.h:
  added using ndb_end and showing mem allocation stat at exit
ndb/src/common/logger/LogHandler.cpp:
  added init of variable
ndb/src/mgmapi/mgmapi.cpp:
  added destruction of LocalConfig to still memleak
  debug printouts
ndb/src/mgmclient/main.cpp:
  added using ndb_end and showing mem allocation stat at exit
ndb/src/mgmsrv/MgmtSrvr.cpp:
  added delete of theFacade on exit
  removed area51
  added debug prints
ndb/src/mgmsrv/main.cpp:
  added using ndb_end and showing mem allocation stat at exit
  moved glob struct to heap to enable ndb_end usage
  moved options out of glob struct
  stopSessions(true) on socket server to ensure destuction of threads
ndb/src/ndbapi/ClusterMgr.cpp:
  added destruction of arbit manager thread
  debug printouts
ndb/src/ndbapi/TransporterFacade.cpp:
  added true option to stopSessions in transporter facade to ensure destructions of threads
  + debug prints
parent 2fdc89da
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
const char *opt_connect_str= 0;\
my_bool	opt_ndb_optimized_node_selection

bool opt_endinfo= 0;
my_bool opt_ndb_shm;

#define OPT_NDB_CONNECTSTRING 'c'
@@ -93,6 +94,7 @@ ndb_std_get_one_option(int optid,
    {
      DBUG_PUSH(argument);
    }
    opt_endinfo= 1;
    break;
  case 'V':
    ndb_std_print_version();
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ LogHandler::LogHandler() :
  m_last_message[0]= 0;
  m_last_log_time= 0;
  m_now= 0;
  m_last_level= (Logger::LoggerLevel)-1;
}

LogHandler::~LogHandler()
+16 −3
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ extern "C"
NdbMgmHandle
ndb_mgm_create_handle()
{
  DBUG_ENTER("ndb_mgm_create_handle");
  NdbMgmHandle h     =
    (NdbMgmHandle)my_malloc(sizeof(ndb_mgm_handle),MYF(MY_WME));
  h->connected       = 0;
@@ -162,17 +163,20 @@ ndb_mgm_create_handle()
  h->logfile = 0;
#endif

  return h;
  DBUG_PRINT("exit",("ret: %lx", h));
  DBUG_RETURN(h);
}

extern "C"
int
ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv)
{
  handle->cfg.~LocalConfig();
  new (&(handle->cfg)) LocalConfig;
  if (!handle->cfg.init(mgmsrv, 0) ||
      handle->cfg.ids.size() == 0)
  {
    handle->cfg.~LocalConfig();
    new (&(handle->cfg)) LocalConfig;
    handle->cfg.init(0, 0); /* reset the LocalCongig */
    SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, "");
@@ -189,8 +193,11 @@ extern "C"
void
ndb_mgm_destroy_handle(NdbMgmHandle * handle)
{
  DBUG_ENTER("ndb_mgm_destroy_handle");
  if(!handle)
    return;
  DBUG_PRINT("enter",("*handle: %lx", *handle));

  if((* handle)->connected){
    ndb_mgm_disconnect(* handle);
  }
@@ -203,6 +210,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle)
  (*handle)->cfg.~LocalConfig();
  my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR));
  * handle = 0;
  DBUG_VOID_RETURN;
}

/*****************************************************************************
@@ -251,6 +259,9 @@ static const Properties *
ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
	     const char *cmd, const Properties *cmd_args) 
{
  DBUG_ENTER("ndb_mgm_call");
  DBUG_PRINT("enter",("handle->socket: %d, cmd: %s",
		      handle->socket, cmd));
  SocketOutputStream out(handle->socket);
  SocketInputStream in(handle->socket, handle->read_timeout);

@@ -310,6 +321,8 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
    /**
     * Print some info about why the parser returns NULL
     */
    DBUG_PRINT("info",("ctx.status: %d, ctx.m_currentToken: %s",
		       ctx.m_status, ctx.m_currentToken));
    //ndbout << " status=" << ctx.m_status << ", curr="
    //<< ctx.m_currentToken << endl;
  } 
@@ -321,9 +334,9 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
    p->print(handle->logfile, "IN: ");
  }
#endif
  return p;
  DBUG_RETURN(p);
#else
   return parser.parse(ctx, session);
  DBUG_RETURN(parser.parse(ctx, session));
#endif
}

+6 −2
Original line number Diff line number Diff line
@@ -44,7 +44,9 @@ static Ndb_mgmclient* com;

extern "C"
void 
handler(int sig){
handler(int sig)
{
  DBUG_ENTER("handler");
  switch(sig){
  case SIGPIPE:
    /**
@@ -54,6 +56,7 @@ handler(int sig){
    com->disconnect();    
    break;
  }
  DBUG_VOID_RETURN;
}

NDB_STD_OPTS_VARS;
@@ -167,6 +170,7 @@ int main(int argc, char** argv){
  }
  delete com;

  ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
  return ret;
}
+7 −18
Original line number Diff line number Diff line
@@ -571,10 +571,11 @@ MgmtSrvr::check_start()
bool 
MgmtSrvr::start(BaseString &error_string)
{
  DBUG_ENTER("MgmtSrvr::start");
  if (_props == NULL) {
    if (!check_start()) {
      error_string.append("MgmtSrvr.cpp: check_start() failed.");
      return false;
      DBUG_RETURN(false);
    }
  }
  theFacade= TransporterFacade::theFacadeInstance= new TransporterFacade();
@@ -582,12 +583,12 @@ MgmtSrvr::start(BaseString &error_string)
  if(theFacade == 0) {
    DEBUG("MgmtSrvr.cpp: theFacade is NULL.");
    error_string.append("MgmtSrvr.cpp: theFacade is NULL.");
    return false;
    DBUG_RETURN(false);
  }  
  if ( theFacade->start_instance
       (_ownNodeId, (ndb_mgm_configuration*)_config->m_configValues) < 0) {
    DEBUG("MgmtSrvr.cpp: TransporterFacade::start_instance < 0.");
    return false;
    DBUG_RETURN(false);
  }

  MGM_REQUIRE(_blockNumber == 1);
@@ -603,7 +604,7 @@ MgmtSrvr::start(BaseString &error_string)
    error_string.append("MgmtSrvr.cpp: _blockNumber is -1.");
    theFacade->stop_instance();
    theFacade = 0;
    return false;
    DBUG_RETURN(false);
  }
  
  _ownReference = numberToRef(_blockNumber, _ownNodeId);
@@ -625,7 +626,7 @@ MgmtSrvr::start(BaseString &error_string)
					"MgmtSrvr_Service",
					NDB_THREAD_PRIO_LOW);

  return true;
  DBUG_RETURN(true);
}


@@ -639,6 +640,7 @@ MgmtSrvr::~MgmtSrvr()

  if(theFacade != 0){
    theFacade->stop_instance();
    delete theFacade;
    theFacade = 0;
  }

@@ -2583,19 +2585,6 @@ MgmtSrvr::repCommand(Uint32* repReqId, Uint32 request, bool waitCompleted)
}


/*****************************************************************************
 * Area 51 ???
 *****************************************************************************/

MgmtSrvr::Area51
MgmtSrvr::getStuff()
{
  Area51 ret;
  ret.theFacade = theFacade;
  ret.theRegistry = theFacade->theTransporterRegistry;
  return ret;
}

NodeId
MgmtSrvr::getPrimaryNode() const {
#if 0
Loading