User: obo     
Date: 05/12/21 05:34:33

Modified:
 /dba/dbaccess/source/core/dataaccess/
  ModelImpl.cxx

Log:
 INTEGRATION: CWS dba202a (1.9.12); FILE MERGED
 2005/11/28 10:50:51 fs 1.9.12.2: #126702# improve the previous fix:
 don't crash if components are destroyed in "wrong" order
 keep mutex alive as long as at least one of 
DataSource/DatabaseDocument/ModelImpl is alive
 2005/11/25 13:37:20 fs 1.9.12.1: #126702# DatabaseDocument and DataSource 
share a common mutex instances now (held by ModelImpl) / 
DatabaseDocument::clearConnections more tolerant against re-entrance

File Changes:

Directory: /dba/dbaccess/source/core/dataaccess/
================================================

File [changed]: ModelImpl.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/ModelImpl.cxx?r1=1.9&r2=1.10
Delta lines:  +42 -6
--------------------
--- ModelImpl.cxx       24 Oct 2005 08:28:12 -0000      1.9
+++ ModelImpl.cxx       21 Dec 2005 13:34:31 -0000      1.10
@@ -117,9 +117,6 @@
 #ifndef _DBA_CORE_CONNECTION_HXX_
 #include "connection.hxx"
 #endif
-#ifndef _COMPHELPER_GUARDING_HXX_
-#include <comphelper/guarding.hxx>
-#endif
 #ifndef _RTL_DIGEST_H_
 #include <rtl/digest.h>
 #endif
@@ -182,6 +179,33 @@
 {
 //........................................................................
 
+//========================================================================
+//= DocumentStorageAccess
+//========================================================================
+//------------------------------------------------------------------------
+SharedMutex::SharedMutex()
+    :m_refCount( 0 )
+{
+}
+
+//------------------------------------------------------------------------
+SharedMutex::~SharedMutex()
+{
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL SharedMutex::acquire()
+{
+    osl_incrementInterlockedCount( &m_refCount );
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL SharedMutex::release()
+{
+    if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+        delete this;
+}
+
 //============================================================
 //= DocumentStorageAccess
 //============================================================
@@ -377,6 +401,7 @@
                        ,m_nLoginTimeout(0)
                        ,m_refCount(0)
             ,m_pStorageAccess( NULL )
+            ,m_xMutex( new SharedMutex )
 {
        // some kind of default
        DBG_CTOR(ODatabaseModelImpl,NULL);
@@ -407,6 +432,7 @@
                        ,m_nLoginTimeout(0)
                        ,m_refCount(0)
             ,m_pStorageAccess( NULL )
+            ,m_xMutex( new SharedMutex )
 {
        DBG_CTOR(ODatabaseModelImpl,NULL);
        // adjust our readonly flag
@@ -472,8 +498,11 @@
 
//------------------------------------------------------------------------------
 void ODatabaseModelImpl::clearConnections()
 {
+    OWeakConnectionArray aConnections;
+    aConnections.swap( m_aConnections );
+
        Reference< XConnection > xConn;
-       for (OWeakConnectionArray::iterator i = m_aConnections.begin(); 
m_aConnections.end() != i; ++i)
+       for ( OWeakConnectionArray::iterator i = aConnections.begin(); 
aConnections.end() != i; ++i )
        {
                xConn = *i;
                if ( xConn.is() )
@@ -488,7 +517,6 @@
                        }
                }
        }
-       m_aConnections.clear();
 
        m_pSharedConnectionManager = NULL;
        m_xSharedConnectionManager = NULL;
@@ -873,6 +901,14 @@
         throw IOException();
     }
 }
+
+// 
-----------------------------------------------------------------------------
+ModelDependentComponent::ModelDependentComponent( const ::rtl::Reference< 
ODatabaseModelImpl >& _model )
+    :m_pImpl( _model )
+    ,m_xMutex( _model->getSharedMutex() )
+{
+}
+
 //........................................................................
 }      // namespace dbaccess
 //........................................................................




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

Reply via email to