List:Commits« Previous MessageNext Message »
From:jonas Date:May 19 2006 7:59am
Subject:bk commit into 5.0 tree (jonas:1.2124) BUG#19930
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jonas. When jonas 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.2124 06/05/19 09:59:34 jonas@stripped +3 -0
  ndb - bug#19930
    Add mutex surronding sessions, as ndb_mgmd now actively tries to go and  "purge stale sessions"

  ndb/src/mgmsrv/Services.cpp
    1.65 06/05/19 09:59:31 jonas@stripped +2 -0
    Add mutex surronding sessions, as ndb_mgmd now actively tries to go and  "purge stale sessions"

  ndb/src/common/util/SocketServer.cpp
    1.19 06/05/19 09:59:31 jonas@stripped +35 -9
    Add mutex surronding sessions, as ndb_mgmd now actively tries to go and  "purge stale sessions"

  ndb/include/util/SocketServer.hpp
    1.9 06/05/19 09:59:31 jonas@stripped +5 -3
    Add mutex surronding sessions, as ndb_mgmd now actively tries to go and  "purge stale sessions"

# 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:	jonas
# Host:	perch.ndb.mysql.com
# Root:	/home/jonas/src/50-work

--- 1.8/ndb/include/util/SocketServer.hpp	2006-04-26 15:13:40 +02:00
+++ 1.9/ndb/include/util/SocketServer.hpp	2006-05-19 09:59:31 +02:00
@@ -105,7 +105,8 @@
   void stopSessions(bool wait = false);
   
   void foreachSession(void (*f)(Session*, void*), void *data);
-
+  void checkSessions();
+  
 private:
   struct SessionInstance {
     Service * m_service;
@@ -116,12 +117,13 @@
     Service * m_service;
     NDB_SOCKET_TYPE m_socket;
   };
-  MutexVector<SessionInstance> m_sessions;
+  NdbLockable m_session_mutex;
+  Vector<SessionInstance> m_sessions;
   MutexVector<ServiceInstance> m_services;
   unsigned m_maxSessions;
   
   void doAccept();
-  void checkSessions();
+  void checkSessionsImpl();
   void startSession(SessionInstance &);
   
   /**

--- 1.18/ndb/src/common/util/SocketServer.cpp	2006-04-26 15:13:40 +02:00
+++ 1.19/ndb/src/common/util/SocketServer.cpp	2006-05-19 09:59:31 +02:00
@@ -184,9 +184,12 @@
 	SessionInstance s;
 	s.m_service = si.m_service;
 	s.m_session = si.m_service->newSession(childSock);
-	if(s.m_session != 0){
+	if(s.m_session != 0)
+	{
+	  m_session_mutex.lock();
 	  m_sessions.push_back(s);
 	  startSession(m_sessions.back());
+	  m_session_mutex.unlock();
 	}
 	
 	continue;
@@ -240,10 +243,13 @@
 SocketServer::doRun(){
 
   while(!m_stopThread){
-    checkSessions();
+    m_session_mutex.lock();
+    checkSessionsImpl();
     if(m_sessions.size() < m_maxSessions){
+      m_session_mutex.unlock();
       doAccept();
     } else {
+      m_session_mutex.unlock();
       NdbSleep_MilliSleep(200);
     }
   }
@@ -276,17 +282,30 @@
 void
 SocketServer::foreachSession(void (*func)(SocketServer::Session*, void *), void *data)
 {
+  m_session_mutex.lock();
   for(int i = m_sessions.size() - 1; i >= 0; i--){
     (*func)(m_sessions[i].m_session, data);
   }
-  checkSessions();
+  m_session_mutex.unlock();
 }
 
 void
-SocketServer::checkSessions(){
-  for(int i = m_sessions.size() - 1; i >= 0; i--){
-    if(m_sessions[i].m_session->m_stopped){
-      if(m_sessions[i].m_thread != 0){
+SocketServer::checkSessions()
+{
+  m_session_mutex.lock();
+  checkSessionsImpl();
+  m_session_mutex.unlock();  
+}
+
+void
+SocketServer::checkSessionsImpl()
+{
+  for(int i = m_sessions.size() - 1; i >= 0; i--)
+  {
+    if(m_sessions[i].m_session->m_stopped)
+    {
+      if(m_sessions[i].m_thread != 0)
+      {
 	void* ret;
 	NdbThread_WaitFor(m_sessions[i].m_thread, &ret);
 	NdbThread_Destroy(&m_sessions[i].m_thread);
@@ -301,19 +320,26 @@
 void
 SocketServer::stopSessions(bool wait){
   int i;
+  m_session_mutex.lock();
   for(i = m_sessions.size() - 1; i>=0; i--)
   {
     m_sessions[i].m_session->stopSession();
     m_sessions[i].m_session->m_stop = true; // to make sure
   }
+  m_session_mutex.unlock();
+  
   for(i = m_services.size() - 1; i>=0; i--)
     m_services[i].m_service->stopSessions();
   
   if(wait){
+    m_session_mutex.lock();
     while(m_sessions.size() > 0){
-      checkSessions();
+      checkSessionsImpl();
+      m_session_mutex.unlock();
       NdbSleep_MilliSleep(100);
+      m_session_mutex.lock();
     }
+    m_session_mutex.unlock();
   }
 }
 
@@ -348,4 +374,4 @@
 }
 
 template class MutexVector<SocketServer::ServiceInstance>;
-template class MutexVector<SocketServer::SessionInstance>;
+template class Vector<SocketServer::SessionInstance>;

--- 1.64/ndb/src/mgmsrv/Services.cpp	2006-05-08 07:56:24 +02:00
+++ 1.65/ndb/src/mgmsrv/Services.cpp	2006-05-19 09:59:31 +02:00
@@ -501,6 +501,7 @@
         ps.tick= tick;
         m_mgmsrv.get_socket_server()->
           foreachSession(stop_session_if_timed_out,&ps);
+	m_mgmsrv.get_socket_server()->checkSessions();
         error_string = "";
         continue;
       }
@@ -1558,6 +1559,7 @@
   ps.free_nodes.bitXORC(NodeBitmask()); // invert connected_nodes to get free nodes
 
   m_mgmsrv.get_socket_server()->foreachSession(stop_session_if_not_connected,&ps);
+  m_mgmsrv.get_socket_server()->checkSessions();
 
   m_output->println("purge stale sessions reply");
   if (str.length() > 0)
Thread
bk commit into 5.0 tree (jonas:1.2124) BUG#19930jonas19 May