From: Date: July 14 2005 5:09pm Subject: bk commit into 4.1 tree (tomas:1.2353) BUG#11898 List-Archive: http://lists.mysql.com/internals/27071 X-Bug: 11898 Message-Id: <20050714150903.09B5B7FF39@poseidon.mysql.com> Below is the list of changes that have just been committed into a local 4.1 repository of tomas. When tomas does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2353 05/07/14 17:08:44 tomas@stripped +4 -0 BUG#11898 ndb_mgmd not releasing resources + debug prints + removed Aread 51 + added delete of TransporterFacade on exit ndb/src/mgmsrv/Services.cpp 1.33 05/07/14 17:08:34 tomas@stripped +76 -17 BUG#11898 ndb_mgmd not releasing resources + debug prints ndb/src/mgmsrv/MgmtSrvr.hpp 1.26 05/07/14 17:08:33 tomas@stripped +1 -10 BUG#11898 ndb_mgmd not releasing resources + debug prints + remover Area51 ndb/src/mgmsrv/MgmtSrvr.cpp 1.60 05/07/14 17:08:33 tomas@stripped +7 -18 BUG#11898 ndb_mgmd not releasing resources + debug prints + removed Aread 51 + added delete of TransporterFacade on exit ndb/src/mgmclient/CommandInterpreter.cpp 1.48 05/07/14 17:08:33 tomas@stripped +28 -6 BUG#11898 ndb_mgmd not releasing resources + debug prints # 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: tomas # Host: poseidon.ndb.mysql.com # Root: /home/tomas/mysql-4.1-new --- 1.47/ndb/src/mgmclient/CommandInterpreter.cpp 2005-06-02 21:13:56 +02:00 +++ 1.48/ndb/src/mgmclient/CommandInterpreter.cpp 2005-07-14 17:08:33 +02:00 @@ -455,11 +455,13 @@ static void* event_thread_run(void* m) { + DBUG_ENTER("event_thread_run"); + NdbMgmHandle handle= *(NdbMgmHandle*)m; int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 }; int fd = ndb_mgm_listen_event(handle, filter); - if (fd > 0) + if (fd != NDB_INVALID_SOCKET) { do_event_thread= 1; char *tmp= 0; @@ -468,20 +470,26 @@ do { if (tmp == 0) NdbSleep_MilliSleep(10); if((tmp = in.gets(buf, 1024))) - ndbout << tmp; + { + const char ping_token[]= ""; + if (memcmp(ping_token,tmp,sizeof(ping_token)-1)) + ndbout << tmp; + } } while(do_event_thread); + NDB_CLOSE_SOCKET(fd); } else { do_event_thread= -1; } - return NULL; + DBUG_RETURN(NULL); } bool CommandInterpreter::connect() { + DBUG_ENTER("CommandInterpreter::connect"); if(!m_connected) { if(!ndb_mgm_connect(m_mgmsrv, try_reconnect-1, 5, 1)) @@ -512,8 +520,19 @@ do_event_thread == 0 || do_event_thread == -1) { - printf("Warning, event thread startup failed, degraded printouts as result\n"); + DBUG_PRINT("info",("Warning, event thread startup failed, " + "degraded printouts as result, errno=%d", + errno)); + printf("Warning, event thread startup failed, " + "degraded printouts as result, errno=%d\n", errno); do_event_thread= 0; + if (m_event_thread) + { + void *res; + NdbThread_WaitFor(m_event_thread, &res); + NdbThread_Destroy(&m_event_thread); + } + ndb_mgm_disconnect(m_mgmsrv2); } } else @@ -521,6 +540,8 @@ printf("Warning, event connect failed, degraded printouts as result\n"); } m_connected= true; + DBUG_PRINT("info",("Connected to Management Server at: %s:%d", + host,port)); if (m_verbose) { printf("Connected to Management Server at: %s:%d\n", @@ -528,12 +549,13 @@ } } } - return m_connected; + DBUG_RETURN(m_connected); } bool CommandInterpreter::disconnect() { + DBUG_ENTER("CommandInterpreter::disconnect"); if (m_event_thread) { void *res; do_event_thread= 0; @@ -550,7 +572,7 @@ } m_connected= false; } - return true; + DBUG_RETURN(true); } //***************************************************************************** --- 1.59/ndb/src/mgmsrv/MgmtSrvr.cpp 2005-04-22 09:07:22 +02:00 +++ 1.60/ndb/src/mgmsrv/MgmtSrvr.cpp 2005-07-14 17:08:33 +02:00 @@ -571,10 +571,11 @@ 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 @@ 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 @@ 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_Service", NDB_THREAD_PRIO_LOW); - return true; + DBUG_RETURN(true); } @@ -639,6 +640,7 @@ if(theFacade != 0){ theFacade->stop_instance(); + delete theFacade; theFacade = 0; } @@ -2582,19 +2584,6 @@ return 0; } - -/***************************************************************************** - * Area 51 ??? - *****************************************************************************/ - -MgmtSrvr::Area51 -MgmtSrvr::getStuff() -{ - Area51 ret; - ret.theFacade = theFacade; - ret.theRegistry = theFacade->theTransporterRegistry; - return ret; -} NodeId MgmtSrvr::getPrimaryNode() const { --- 1.25/ndb/src/mgmsrv/MgmtSrvr.hpp 2005-04-22 09:07:22 +02:00 +++ 1.26/ndb/src/mgmsrv/MgmtSrvr.hpp 2005-07-14 17:08:33 +02:00 @@ -60,6 +60,7 @@ } void add_listener(const Event_listener&); + void check_listeners(); void update_max_log_level(const LogLevel&); void update_log_level(const LogLevel&); @@ -764,16 +765,6 @@ int send(class NdbApiSignal* signal, Uint32 node, Uint32 node_type); ConfigRetriever *m_config_retriever; - -public: - /** - * This method does not exist - */ - struct Area51 { - class TransporterFacade * theFacade; - class TransporterRegistry * theRegistry; - }; - Area51 getStuff(); }; inline --- 1.32/ndb/src/mgmsrv/Services.cpp 2004-12-17 10:32:22 +01:00 +++ 1.33/ndb/src/mgmsrv/Services.cpp 2005-07-14 17:08:34 +02:00 @@ -253,15 +253,19 @@ }; MgmApiSession::MgmApiSession(class MgmtSrvr & mgm, NDB_SOCKET_TYPE sock) - : SocketServer::Session(sock), m_mgmsrv(mgm) { + : SocketServer::Session(sock), m_mgmsrv(mgm) +{ + DBUG_ENTER("MgmApiSession::MgmApiSession"); m_input = new SocketInputStream(sock); m_output = new SocketOutputStream(sock); m_parser = new Parser_t(commands, *m_input, true, true, true); m_allocated_resources= new MgmtSrvr::Allocated_resources(m_mgmsrv); + DBUG_VOID_RETURN; } MgmApiSession::~MgmApiSession() { + DBUG_ENTER("MgmApiSession::~MgmApiSession"); if (m_input) delete m_input; if (m_output) @@ -270,10 +274,19 @@ delete m_parser; if (m_allocated_resources) delete m_allocated_resources; + if(m_socket != NDB_INVALID_SOCKET) + { + NDB_CLOSE_SOCKET(m_socket); + m_socket= NDB_INVALID_SOCKET; + } + DBUG_VOID_RETURN; } void -MgmApiSession::runSession() { +MgmApiSession::runSession() +{ + DBUG_ENTER("MgmApiSession::runSession"); + Parser_t::Context ctx; while(!m_stop) { m_parser->run(ctx, *this); @@ -301,8 +314,13 @@ break; } } - if(m_socket >= 0) + if(m_socket != NDB_INVALID_SOCKET) + { NDB_CLOSE_SOCKET(m_socket); + m_socket= NDB_INVALID_SOCKET; + } + + DBUG_VOID_RETURN; } #ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT @@ -1236,7 +1254,7 @@ Uint32 threshold; LogLevel::EventCategory cat; Logger::LoggerLevel severity; - int i; + int i, n; DBUG_ENTER("Ndb_mgmd_event_service::log"); DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId)); @@ -1248,28 +1266,30 @@ Vector copy; m_clients.lock(); - for(i = m_clients.size() - 1; i >= 0; i--){ - if(threshold <= m_clients[i].m_logLevel.getLogLevel(cat)){ - if(m_clients[i].m_socket != NDB_INVALID_SOCKET && - println_socket(m_clients[i].m_socket, - MAX_WRITE_TIMEOUT, m_text) == -1){ - copy.push_back(m_clients[i].m_socket); + for(i = m_clients.size() - 1; i >= 0; i--) + { + if(threshold <= m_clients[i].m_logLevel.getLogLevel(cat)) + { + int fd= m_clients[i].m_socket; + if(fd != NDB_INVALID_SOCKET && + println_socket(fd, MAX_WRITE_TIMEOUT, m_text) == -1) + { + copy.push_back(fd); m_clients.erase(i, false); } } } m_clients.unlock(); - for(i = 0; (unsigned)i < copy.size(); i++){ - NDB_CLOSE_SOCKET(copy[i]); - } + if ((n= (int)copy.size())) + { + for(i= 0; i < n; i++) + NDB_CLOSE_SOCKET(copy[i]); - if(copy.size()){ LogLevel tmp; tmp.clear(); m_clients.lock(); - for(i = 0; (unsigned)i < m_clients.size(); i++){ + for(i= m_clients.size() - 1; i >= 0; i--) tmp.set_max(m_clients[i].m_logLevel); - } m_clients.unlock(); update_log_level(tmp); } @@ -1297,9 +1317,48 @@ } void -Ndb_mgmd_event_service::add_listener(const Event_listener& client){ +Ndb_mgmd_event_service::check_listeners() +{ + int i, n= 0; + DBUG_ENTER("Ndb_mgmd_event_service::check_listeners"); + m_clients.lock(); + for(i= m_clients.size() - 1; i >= 0; i--) + { + int fd= m_clients[i].m_socket; + DBUG_PRINT("info",("%d %d",i,fd)); + char buf[1]; + buf[0]=0; + if (fd != NDB_INVALID_SOCKET && + println_socket(fd,MAX_WRITE_TIMEOUT,"") == -1) + { + NDB_CLOSE_SOCKET(fd); + m_clients.erase(i, false); + n=1; + } + } + if (n) + { + LogLevel tmp; tmp.clear(); + for(i= m_clients.size() - 1; i >= 0; i--) + tmp.set_max(m_clients[i].m_logLevel); + update_log_level(tmp); + } + m_clients.unlock(); + DBUG_VOID_RETURN; +} + +void +Ndb_mgmd_event_service::add_listener(const Event_listener& client) +{ + DBUG_ENTER("Ndb_mgmd_event_service::add_listener"); + DBUG_PRINT("enter",("client.m_socket: %d", client.m_socket)); + + check_listeners(); + m_clients.push_back(client); update_max_log_level(client.m_logLevel); + + DBUG_VOID_RETURN; } void