List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:November 23 2007 8:41pm
Subject:Rev 243: Merged bugfixes. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/telco-6.3
View as plain text  
At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/telco-6.3

------------------------------------------------------------
revno: 243
revision-id: mtaylor@stripped
parent: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: telco-6.3
timestamp: Fri 2007-11-23 12:40:49 -0800
message:
  Merged bugfixes. 
modified:
  configure.in                   configure.in-20070228020914-u2pk759xg7thauwf-13
  interface/mgmapi/NdbLogEventManager.i
ndbmgmlogeventhandle-20070906065939-pj4qrhof8kkzg3d1-1
    ------------------------------------------------------------
    revno: 192.1.25.1.65
    revision-id: mtaylor@stripped
    parent: mtaylor@stripped
    committer: Monty Taylor <mtaylor@stripped>
    branch nick: devel
    timestamp: Fri 2007-11-23 12:36:51 -0800
    message:
      BUG#32671 ndb-connector java compilation fails with "/bin/sh: no: command not found"
      Added a test and failure condition if we don't find a Java we know how to deal with.

    modified:
      configure.in                   configure.in-20070228020914-u2pk759xg7thauwf-13
    ------------------------------------------------------------
    revno: 192.1.25.1.64
    revision-id: mtaylor@stripped
    parent: mtaylor@stripped
    committer: Monty Taylor <mtaylor@stripped>
    branch nick: devel
    timestamp: Fri 2007-11-23 12:16:50 -0800
    message:
      BUG#32669 ndb-connectors rely on not yet standard map::at() method
      Replaced calls to map::at with calls to map::find() followed by map::operator[].
      As a side effect of this, NDB/Connectors no longer employs C++ exceptions, so  
      integration with the mainline code using -fno-exceptions will be easier.  
    modified:
      interface/mgmapi/NdbLogEventManager.i
ndbmgmlogeventhandle-20070906065939-pj4qrhof8kkzg3d1-1
=== modified file 'configure.in'
--- a/configure.in	2007-11-22 18:31:23 +0000
+++ b/configure.in	2007-11-23 20:40:49 +0000
@@ -53,6 +53,7 @@
 
 
 WITH_JAVA()
+AS_IF([test "x$JAVAC" = "xno"],AC_MSG_ERROR([Unknown or unsupported JDK]))
 
 WITH_CSHARP()
 

=== modified file 'interface/mgmapi/NdbLogEventManager.i'
--- a/interface/mgmapi/NdbLogEventManager.i	2007-11-20 01:45:07 +0000
+++ b/interface/mgmapi/NdbLogEventManager.i	2007-11-23 20:16:50 +0000
@@ -66,33 +66,43 @@
     // Returns -1 on error, 0 otherwise
     int registerListener(NdbLogEventTypeListener * listener) { 
       Ndb_logevent_type theType = listener->getEventType();
-      
-      
-      evtListeners.insert(std::make_pair<Ndb_logevent_type,NdbLogEventTypeListener
*>(theType,listener));
-	
-      
-      return 0;
+
+      std::map<Ndb_logevent_type,NdbLogEventTypeListener *>::iterator it; 
+      it=evtListeners.find(theType);
+      if (it==evtListeners.end()) { 
+	// We don't have this one yet
+	evtListeners[theType]=listener;
+	return 0;
+      }       
+      // Must unregisterListener first
+      return -1;
     }
     
+    // Returns -1 on error, 0 otherwise
+    int registerListener(NdbLogEventCategoryListener * listener) { 
+      ndb_mgm_event_category theCategory = listener->getEventCategory();
+      
+
+      std::map<ndb_mgm_event_category,NdbLogEventCategoryListener *>::iterator it; 
+      it=evtCategoryListeners.find(theCategory);
+      
+      if(it==evtCategoryListeners.end()) { 
+	evtCategoryListeners[theCategory]=listener;
+	return 0; 
+      } 
+      return -1;
+    }
+ 
     bool unregisterListener(NdbLogEventTypeListener * listener) { 
+      evtListeners.erase(evtListeners.find(listener->getEventType()));
       return true;
     }
-    // Returns -1 on error, 0 otherwise
-    int registerCategoryListener(NdbLogEventCategoryListener * listener) { 
-      ndb_mgm_event_category theCategory = listener->getEventCategory();
-      
-      
-      NdbLogEventCategoryListener * evtLis; 
-
-      
-      try {
-	evtLis = evtCategoryListeners.at(theCategory);
-      } catch (std::out_of_range e) { 
-	if
(!((evtCategoryListeners.insert(std::make_pair<ndb_mgm_event_category,NdbLogEventCategoryListener*>(theCategory,evtLis))).second))
{
-	  return -1;
-	}
-      }; 
-      return 0;
+    bool unregisterListener(NdbLogEventCategoryListener * listener) { 
+      evtCategoryListeners.erase
+	(
+	 evtCategoryListeners.find(listener->getEventCategory())
+	 );
+      return true;
     }
     
     
@@ -119,28 +129,21 @@
       if (eventWrapper->ret > 0) { 
 	eventWrapper->theEvent = event;
 	
-	NdbLogEventTypeListener * evtLis = NULL;
-	NdbLogEventCategoryListener * catLis = NULL;
-	
-	try {
-	  evtLis = evtListeners.at(event->type);
-	  
-	} catch (std::out_of_range e) { 
-	  // We don't have a listener to fire
-	}
-	if (evtLis != NULL) { 
-	  evtLis->handleEvent(event);
-	}
-	try {
-	  catLis = evtCategoryListeners.at(event->category);
-	  
-	} catch (std::out_of_range e) { 
-	  // We don't have a listener to fire
-	}
-	if (catLis != NULL) { 
-	  catLis->handleEvent(event);
-	}
-
+	{
+	  std::map<Ndb_logevent_type,NdbLogEventTypeListener *>::iterator it; 
+	  it=evtListeners.find(event->type);
+	  if (it!=evtListeners.end()) {
+	    ((*it).second)->handleEvent(event);
+	  }
+	}
+	{
+	  std::map<ndb_mgm_event_category,NdbLogEventCategoryListener *>::iterator it; 
+	  it=evtCategoryListeners.find(event->category);
+	  
+	  if(it!=evtCategoryListeners.end()) { 
+	    ((*it).second)->handleEvent(event);
+	  }
+	}
 	// r > 0, event exists; 
 	// r==0, no event (timeout)
 	// r==-1, error
@@ -203,9 +206,18 @@
 public: 
   // Returns -1 on error, 0 otherwise
   ~NdbLogEventManager();
+  bool unregisterListener(NdbLogEventTypeListener * listener);
+  bool unregisterListener(NdbLogEventCategoryListener * listener);
+
+  %ndbexception("MgmApiException") { 
+    $action
+      if (result < 0) { 
+	NDB_exception(NdbApiException,"Must deregister handler before adding a new one");
+      }
+  }
   int registerListener(NdbLogEventTypeListener * listener);   
-  bool unregisterListener(NdbLogEventTypeListener * listener);
-  int registerCategoryListener(NdbLogEventCategoryListener * listener);
+  int registerListener(NdbLogEventCategoryListener * listener);
+
 
   %ndbexception("MgmApiException") { 
     $action

Thread
Rev 243: Merged bugfixes. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/telco-6.3Monty Taylor23 Nov