Date: Monday, February 12, 2007 @ 18:53:30
  Author: gilles
    Path: /cvsroot/carob/carob/src

Modified: ControllerPool.cpp (1.20 -> 1.21)

Better documentation of object ownerships
Fixed potential memory leak (not deleting watcher upon ConnectionException) + 
bug fix (no more deletion of callback, which is owned by watcher)


--------------------+
 ControllerPool.cpp |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)


Index: carob/src/ControllerPool.cpp
diff -u carob/src/ControllerPool.cpp:1.20 carob/src/ControllerPool.cpp:1.21
--- carob/src/ControllerPool.cpp:1.20   Wed Feb  7 16:32:33 2007
+++ carob/src/ControllerPool.cpp        Mon Feb 12 18:53:30 2007
@@ -58,13 +58,15 @@
     alive_controllers.push_back(ControllerAndVdbState(*iter));
   }
 
-  // Create the objects for controller watcher
+  // Create callback for the controller watcher. Ownership is transfered to the
+  // WatchedControllers instance of the controller watcher
   callback_ptr = new SocketKillerCallback(*this);
   try
   {
     // Since the destruction of the watcher can be long (waiting for select
     // timeout), the property of this watcher instance + the callback instance
-    // is transfered to the ControllerWatcherThread C function
+    // is transfered to the ControllerWatcherThread C function (unless a 
+    // connection exception is thrown)
     watcher_ptr = new ControllerWatcher(controllerList, callback_ptr,
         pingDelayInMs, controllerTimeoutInMs);
     pthread_create(&watcher_thread, NULL, ControllerWatcherThread, 
watcher_ptr);
@@ -73,7 +75,7 @@
   catch (ConnectionException cause)
   {
     alive_controllers.clear();
-    delete callback_ptr;
+    delete watcher_ptr;
     throw DriverException(
         L"Controller watcher creation failed!");
   }

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to