Tag: cws_src680_kabrefine
User: fs      
Date: 06/01/04 03:33:58

Modified:
 /dba/connectivity/source/drivers/kab/
  KDriver.cxx, KDriver.hxx

Log:
 #i59673# don't attempt to load the impl lib more than once, if the first 
attempt failed

File Changes:

Directory: /dba/connectivity/source/drivers/kab/
================================================

File [changed]: KDriver.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/KDriver.cxx?r1=1.2.10.1&r2=1.2.10.2
Delta lines:  +14 -3
--------------------
--- KDriver.cxx 4 Jan 2006 11:22:58 -0000       1.2.10.1
+++ KDriver.cxx 4 Jan 2006 11:33:55 -0000       1.2.10.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: KDriver.cxx,v $
  *
- *  $Revision: 1.2.10.1 $
+ *  $Revision: 1.2.10.2 $
  *
- *  last change: $Author: fs $ $Date: 2006/01/04 11:22:58 $
+ *  last change: $Author: fs $ $Date: 2006/01/04 11:33:55 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -50,6 +50,7 @@
        : KDriver_BASE(m_aMutex),
          m_xMSFactory(_rxFactory),
       m_hConnectorModule(NULL),
+      m_bInitializedConnectorModule(false),
       m_pConnectionFactoryFunc(NULL),
       m_pApplicationInitFunc(NULL),
       m_pApplicationShutdownFunc(NULL)
@@ -115,6 +116,8 @@
 // 
--------------------------------------------------------------------------------
 Reference< XConnection > SAL_CALL KabDriver::connect( const ::rtl::OUString& 
url, const Sequence< PropertyValue >& info ) throw(SQLException, 
RuntimeException)
 {
+    ::osl::MutexGuard aGuard(m_aMutex);
+
     if ( !impl_initImplementationModule() )
         return NULL;
 
@@ -141,6 +144,8 @@
 sal_Bool SAL_CALL KabDriver::acceptsURL( const ::rtl::OUString& url )
                throw(SQLException, RuntimeException)
 {
+    ::osl::MutexGuard aGuard(m_aMutex);
+
     if ( !impl_initImplementationModule() )
         return sal_False;
 
@@ -197,7 +202,11 @@
 // 
--------------------------------------------------------------------------------
 bool KabDriver::impl_initImplementationModule()
 {
-    // TODO: this is not thread-safe
+    if ( m_bInitializedConnectorModule )
+        return ( m_hConnectorModule != NULL );
+
+    // prevent multiple attempts to load the lib. This could be expensive in 
case of errors.
+    m_bInitializedConnectorModule = true;
 
     if ( !m_hConnectorModule )
     {
@@ -235,4 +244,6 @@
     m_pConnectionFactoryFunc = NULL;
     m_pApplicationInitFunc = NULL;
     m_pApplicationShutdownFunc = NULL;
+
+    m_bInitializedConnectorModule = false;
 }

File [changed]: KDriver.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/KDriver.hxx?r1=1.2.10.1&r2=1.2.10.2
Delta lines:  +7 -2
-------------------
--- KDriver.hxx 4 Jan 2006 11:22:58 -0000       1.2.10.1
+++ KDriver.hxx 4 Jan 2006 11:33:55 -0000       1.2.10.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: KDriver.hxx,v $
  *
- *  $Revision: 1.2.10.1 $
+ *  $Revision: 1.2.10.2 $
  *
- *  last change: $Author: fs $ $Date: 2006/01/04 11:22:58 $
+ *  last change: $Author: fs $ $Date: 2006/01/04 11:33:55 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -77,6 +77,7 @@
 
             // dynamic access to the library which implements the "real" 
functionality
             oslModule                   m_hConnectorModule;
+            bool                        m_bInitializedConnectorModule;
             ConnectionFactoryFunction   m_pConnectionFactoryFunc;
             ApplicationInitFunction     m_pApplicationInitFunc;
             ApplicationShutdownFunction m_pApplicationShutdownFunc;
@@ -113,12 +114,16 @@
             /** initializes the library which contains the real implementations
 
                 @return <TRUE/> if and only if loading the library succeeded, 
and <em>all</em> needed symbols were found
+
+                @precond our mutex is locked
             */
             bool impl_initImplementationModule();
 
             /** shuts down the library which contains the real implementations
 
                 This method is safe against being called multiple times
+
+                @precond our mutex is locked
             */
             void impl_shutdownImplementationModule();
                };




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to