Date: Wednesday, November 29, 2006 @ 20:36:49
  Author: gilles
    Path: /cvsroot/carob/carob

Modified: include/Connection.hpp (1.73 -> 1.74) src/Connection.cpp (1.95
          -> 1.96)

Fixed much method signature to throw DriverException (thrown by reconnection)
Now delete driver socket in closeSocket(). The socket closure is done in 
DriverSocket destructor, no need to do it here
Removed ConnectionException catch in reconnectOrDie(). As we don't reconnect to 
the same controller anymore, just let this exception go up
Fixed debug messages


------------------------+
 include/Connection.hpp |   25 +++++++----------
 src/Connection.cpp     |   66 +++++++++++++++++------------------------------
 2 files changed, 36 insertions(+), 55 deletions(-)


Index: carob/include/Connection.hpp
diff -u carob/include/Connection.hpp:1.73 carob/include/Connection.hpp:1.74
--- carob/include/Connection.hpp:1.73   Tue Aug 29 21:57:24 2006
+++ carob/include/Connection.hpp        Wed Nov 29 20:36:49 2006
@@ -252,7 +252,7 @@
    * @throw SocketIOException if an error occurs on the socket
    */
   DriverResultSet*  statementExecuteQuery(RequestWithResultSetParameters& 
request)
-                        throw (SocketIOException, BackendException, 
+                        throw (SocketIOException, BackendException, 
DriverException,
                         ControllerException, ProtocolException,
                         NotImplementedException, ConnectionException,
                         UnexpectedException);
@@ -265,7 +265,7 @@
    */
   ResultAndWarnings statementExecuteUpdate(Request& r)
                         throw (SocketIOException, BackendException, 
-                        ControllerException, ProtocolException,
+                        ControllerException, DriverException, 
ProtocolException,
                         ConnectionException, UnexpectedException);
   /**
    * Calls a request that returns a list of results and the optionnal warnings.
@@ -278,10 +278,9 @@
    * @throws SocketIOException if an error occurs
    */
   ResultAndWarnings statementExecute(RequestWithResultSetParameters& request)
-                                        throw (SocketIOException,
-                                        BackendException, ControllerException,
-                                        ProtocolException, ConnectionException,
-                                        UnexpectedException);
+                        throw (SocketIOException, BackendException, 
+                        ControllerException, DriverException, 
ProtocolException,
+                        ConnectionException, UnexpectedException);
   /**
    * Performs a write request and returns the auto-generated keys
    * 
@@ -292,12 +291,10 @@
    *          DriverResultSet containing the autogenerated keys
    * @throws SocketIOException if an error occurs
    */
-  ResultAndWarnings statementExecuteUpdateWithKeys(
-                                        Request &request)
-                                        throw (SocketIOException,
-                                        BackendException,ControllerException,
-                                        ProtocolException, ConnectionException,
-                                        UnexpectedException);
+  ResultAndWarnings statementExecuteUpdateWithKeys(Request &request)
+                        throw (SocketIOException, BackendException, 
+                        ControllerException, DriverException, 
ProtocolException,
+                        ConnectionException, UnexpectedException);
   /**
    * Closes the remote ResultSet given its cursor name.
    * 
@@ -346,7 +343,7 @@
    */
   DriverResultSet*  preparedStatementGetMetaData(const std::wstring& 
sqlTemplate)
                           throw (SocketIOException, BackendException,
-                          ProtocolException, ControllerException,
+                          DriverException, ProtocolException, 
ControllerException,
                           NotImplementedException, ConnectionException,
                           UnexpectedException);
   /**
@@ -490,7 +487,7 @@
    * set to <code>true</code>).
    */
   void                beginTransactionIfNeeded() throw (SocketIOException,
-                          BackendException, ControllerException, 
+                          BackendException, ControllerException, 
DriverException,
                           ProtocolException, ConnectionException,
                           UnexpectedException);
 
Index: carob/src/Connection.cpp
diff -u carob/src/Connection.cpp:1.95 carob/src/Connection.cpp:1.96
--- carob/src/Connection.cpp:1.95       Wed Nov 29 18:06:17 2006
+++ carob/src/Connection.cpp    Wed Nov 29 20:36:49 2006
@@ -74,6 +74,7 @@
   autoCommit(true),
   readOnly(false),
   writeExecutedInTransaction(false),
+  transactionId(-1),
   mustBeginTransaction(false),
   persistent_connection(false),
   retrieve_sql_warnings(false),
@@ -134,7 +135,7 @@
 Connection::~Connection()
 {
   close();
-  delete driverSocketPtr;
+  // driverSocketPtr is deleted in close()
   parameters.releaseControllerPool();
 }
 
@@ -359,7 +360,7 @@
 
   if (driverSocketPtr == NULL)
   {
-    return false;
+    return true;
   }
 
   if (isDebugEnabled())
@@ -372,25 +373,14 @@
   }
   catch (...)
   {
-    if (isWarnEnabled())
-      logWarn(fctName, L"Could not inform controller we are closing 
connection");
-  }
-  try
-  {
-    //now close the socket itself
-    closeOK &= driverSocketPtr->closeSocket();
-    return closeOK;
-  }
-  //catch any exception, log an error and return false (no exception forward)
-  catch (...)
-  {
-    if (isWarnEnabled())
-    {
-      logWarn(fctName, L"Caught exception while closing connection");
-    }
-    //Don't re-throw = transparent closing
+    if (isInfoEnabled())
+      logInfo(fctName, L"Could not inform controller we are closing 
connection");
   }
-  return false;
+  // socket closing will be done in destructor
+  delete driverSocketPtr;
+  driverSocketPtr = NULL;
+
+  return closeOK;
 }
 
 void Connection::setAutoCommit(bool autoCommitPrm)
@@ -433,21 +423,23 @@
     autoCommit = false;
 
     if (isDebugEnabled())
-      logDebug(fctName, L"Transaction" + toUserString(transactionId)
-                        + L" has been started");
+      logDebug(fctName, L"autocommit set to false, next transaction will do a 
'Begin'");
   }
 }
 
 void Connection::beginTransactionIfNeeded() throw (SocketIOException,
-    BackendException, ControllerException, ProtocolException,
+    BackendException, ControllerException, DriverException, ProtocolException,
     ConnectionException, UnexpectedException)
 {
+  wstring fctName(L"Connection::beginTransactionIfNeeded");
   if (mustBeginTransaction)
   {
     FO_TRY_NTIMES(RECONNECT_RETRIES)
       sendCommand(*driverSocketPtr, Begin);
       transactionId = receiveLongOrException();
       mustBeginTransaction = false;
+      if (isDebugEnabled())
+        logDebug(fctName, L"Begin transaction done. Transaction id=" + 
toWString(transactionId));
     FO_CATCH_NTIMES
   }
 }
@@ -608,7 +600,7 @@
 }
 
 DriverResultSet* Connection::preparedStatementGetMetaData(const wstring 
&sqlTemplate)
-    throw (SocketIOException, BackendException, ControllerException, 
+    throw (SocketIOException, BackendException, ControllerException, 
DriverException, 
     ProtocolException, NotImplementedException, ConnectionException,
     UnexpectedException)
 {
@@ -635,13 +627,12 @@
   request.setIsAutoCommit(autoCommit);
 }
 
-DriverResultSet* Connection::statementExecuteQuery
-    (RequestWithResultSetParameters& request)
+DriverResultSet* 
Connection::statementExecuteQuery(RequestWithResultSetParameters& request)
     throw (SocketIOException, BackendException, ControllerException,
-    ProtocolException, NotImplementedException, ConnectionException,
-    UnexpectedException)
+    DriverException, ProtocolException, NotImplementedException,
+    ConnectionException, UnexpectedException)
 {
-  
+
   wstring fctName(L"Connection::statementExecuteQuery");
 
   LockScope ls(&connectionCS);
@@ -672,7 +663,7 @@
 
 ResultAndWarnings Connection::statementExecuteUpdate(Request& request)
     throw (SocketIOException, BackendException, ControllerException,
-    ProtocolException, ConnectionException, UnexpectedException)
+    DriverException, ProtocolException, ConnectionException, 
UnexpectedException)
 {
   wstring fctName(L"Connection::statementExecuteUpdate");
 
@@ -727,7 +718,7 @@
 
 ResultAndWarnings Connection::statementExecute(
     RequestWithResultSetParameters& request) throw (SocketIOException,
-    BackendException, ControllerException, ProtocolException,
+    BackendException, ControllerException, DriverException, ProtocolException,
     ConnectionException, UnexpectedException)
 {
   wstring fctName(L"Connection::statementExecute");
@@ -787,7 +778,7 @@
 
 ResultAndWarnings Connection::statementExecuteUpdateWithKeys(
     Request &request) throw (SocketIOException, BackendException,
-    ControllerException, ProtocolException, ConnectionException,
+    ControllerException, DriverException, ProtocolException, 
ConnectionException,
     UnexpectedException)
 {
   wstring fctName(L"Connection::statementExecuteUpdateWithKeys");
@@ -1221,13 +1212,6 @@
       tryToReconnect();
       reconnected = true;
     }
-    catch (ConnectionException ce)
-    {
-      if (isDebugEnabled())
-        logDebug(fctName, L"Controller "
-            + static_cast<wstring>(connected_controller)
-            + L" seams to be down - giving it a last chance...");
-    }
     catch (NoMoreControllerException nmce)
     {
       throw (ConnectionException(nmce.description()));
@@ -1277,10 +1261,10 @@
   {
     // Should not happen, this probably mean an inconsistency in controller
     // configuration but safely ignore (see below)
-    wstring msg = L"Warning! Authentication exception received on connection 
retry, controller configuration might be inconsistent";
+    wstring msg = L"Warning! Authentication exception received on connection 
retry, controller configuration might be inconsistent.";
     if (isWarnEnabled())
       logWarn(fctName, msg);
-    throw DriverException(msg+ae.description());
+    throw DriverException(msg+ L" Exception:" + ae.description());
   }
 
   // Connection succeeded, restore the previous connection state on the

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

Reply via email to