summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-06-10 12:27:02 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-06-10 12:36:54 +0200
commit670100fcfbb39d3dbe4afdb27fbced26d7b14283 (patch)
treea433d34f1cdc43d7ad60711b0ddce483ea32a0cb
parent6f9b3532ee81850500d9e87ad329c00ea9c83bba (diff)
Remove FastLoader optimization
...that was introduced in b88a62cc97613e5dc00c806f59982cb57f9d1dc8 "CWS-TOOLING: integrate CWS dbaperf2," apparently to speed up later activity by pre-loading a JVM or Calc. The problem is that any spawned FastLoader thread was never joined, so could still run during exit. That caused many spurious failures of CppunitTest_sw_uiwriter after df726c8b3e80bf2e1696f901ea01f192dcb8a77e "CppunitTest_sw_uiwriter: add embedded data source definition testcase" triggered spawning such FastLoader threads there. Adding code to join any spawned FastLoader thread is not easy, though. For one, it is not clear whether there would not be very many (terminated, waiting to be joined, thus still holding up system resources) such treads when doing the join in ~DatasourceURLListener or DatasourceURLListener::disposing. For another, a naive attempt at joining in ~DatasourceURLListener leads to deadlock, as it is called with the SolarMutex locked and the E_CALC branch in FastLoader::run blocks waiting to acquire it. Thus, the best approach appears to be to remove this optimization. Hopefully, that does not have too dire performance impacts on typcial user scenarios. Change-Id: Ifeab013ddd8acee1289423facba0c120684e9325
-rw-r--r--dbaccess/source/filter/xml/xmlfilter.cxx156
1 files changed, 0 insertions, 156 deletions
diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx
index 0d0ee5a9a4e5..9b37f0565289 100644
--- a/dbaccess/source/filter/xml/xmlfilter.cxx
+++ b/dbaccess/source/filter/xml/xmlfilter.cxx
@@ -20,14 +20,10 @@
#include <sal/config.h>
#include <boost/noncopyable.hpp>
-#include <config_features.h>
#include <com/sun/star/util/MeasureUnit.hpp>
#include <com/sun/star/packages/zip/ZipIOException.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
-#if HAVE_FEATURE_JAVA
-#include <jvmaccess/virtualmachine.hxx>
-#endif
#include "xmlfilter.hxx"
#include "xmlservices.hxx"
#include "flt_reghelper.hxx"
@@ -52,24 +48,16 @@
#include <xmloff/xmluconv.hxx>
#include "xmlHelper.hxx"
#include <com/sun/star/util/XModifiable.hpp>
-#include <com/sun/star/frame/Desktop.hpp>
-#include <com/sun/star/frame/XComponentLoader.hpp>
-#include <com/sun/star/frame/FrameSearchFlag.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <osl/mutex.hxx>
#include <svtools/sfxecode.hxx>
-#include <unotools/moduleoptions.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/diagnose_ex.h>
#include <osl/diagnose.h>
#include <comphelper/processfactory.hxx>
#include <comphelper/namedvaluecollection.hxx>
-#include <comphelper/mimeconfighelper.hxx>
-#include <comphelper/documentconstants.hxx>
#include <comphelper/uno3.hxx>
#include <cppuhelper/exc_hlp.hxx>
-#include <osl/thread.hxx>
-#include <connectivity/CommonTools.hxx>
#include <connectivity/DriversConfig.hxx>
#include "dsntypes.hxx"
#include <rtl/strbuf.hxx>
@@ -83,148 +71,6 @@ extern "C" void SAL_CALL createRegistryInfo_ODBFilter( )
namespace dbaxml
{
- namespace
- {
- class FastLoader : public ::osl::Thread
- {
- public:
- typedef enum { E_JAVA, E_CALC } StartType;
- FastLoader(uno::Reference< uno::XComponentContext > const & _xContext,StartType _eType)
- :m_xContext(_xContext)
- ,m_eWhat(_eType)
- {}
-
- protected:
- virtual ~FastLoader(){}
-
- /// Working method which should be overridden.
- virtual void SAL_CALL run() SAL_OVERRIDE;
- virtual void SAL_CALL onTerminated() SAL_OVERRIDE;
- private:
- uno::Reference< uno::XComponentContext > m_xContext;
- StartType m_eWhat;
- };
-
- void SAL_CALL FastLoader::run()
- {
- osl_setThreadName("dbaxml::FastLoader");
-
- if ( m_eWhat == E_JAVA )
- {
-#if HAVE_FEATURE_JAVA
- static bool s_bFirstTime = true;
- if ( s_bFirstTime )
- {
- s_bFirstTime = false;
- try
- {
- ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_xContext);
- }
- catch (const uno::Exception&)
- {
- OSL_ASSERT(false);
- }
- }
-#endif
- }
- else if ( m_eWhat == E_CALC )
- {
- static bool s_bFirstTime = true;
- if ( s_bFirstTime )
- {
- s_bFirstTime = false;
- try
- {
- uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create( m_xContext );
- const OUString sTarget("_blank");
- sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
- uno::Reference< frame::XFrame> xFrame = xDesktop->findFrame(sTarget,nFrameSearchFlag);
- uno::Reference<frame::XComponentLoader> xFrameLoad(xFrame,uno::UNO_QUERY);
-
- if ( xFrameLoad.is() )
- {
- uno::Sequence < beans::PropertyValue > aArgs( 3);
- sal_Int32 nLen = 0;
- aArgs[nLen].Name = "AsTemplate";
- aArgs[nLen++].Value <<= sal_False;
-
- aArgs[nLen].Name = "ReadOnly";
- aArgs[nLen++].Value <<= sal_True;
-
- aArgs[nLen].Name = "Hidden";
- aArgs[nLen++].Value <<= sal_True;
-
- ::comphelper::MimeConfigurationHelper aHelper( m_xContext );
- SvtModuleOptions aModuleOptions;
- // This looks like it makes no sense,
- // but is probably used to lower latency
- // of the user interface for the user:
- // when the user will do anything that requires
- // the data connection to be established,
- // calc will already have been loaded, initialised, etc
- // so establishing the data connection (to a Calc sheet)
- // will be "faster".
- uno::Reference< frame::XModel > xModel(xFrameLoad->loadComponentFromURL(
- aModuleOptions.GetFactoryEmptyDocumentURL( SvtModuleOptions::ClassifyFactoryByServiceName( aHelper.GetDocServiceNameFromMediaType(MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII) )),
- OUString(), // empty frame name
- 0,
- aArgs
- ),uno::UNO_QUERY);
- ::comphelper::disposeComponent(xModel);
- }
- }
- catch (const uno::Exception&)
- {
- OSL_ASSERT(false);
- }
- }
- }
- }
- void SAL_CALL FastLoader::onTerminated()
- {
- delete this;
- }
-
- class DatasourceURLListener:
- public cppu::WeakImplHelper1<beans::XPropertyChangeListener>,
- private boost::noncopyable
- {
- uno::Reference< uno::XComponentContext > m_xContext;
- ::dbaccess::ODsnTypeCollection m_aTypeCollection;
- protected:
- virtual ~DatasourceURLListener(){}
- public:
- DatasourceURLListener(uno::Reference< uno::XComponentContext > const & _xContext) : m_xContext(_xContext), m_aTypeCollection(_xContext){}
- // XPropertyChangeListener
- virtual void SAL_CALL propertyChange( const beans::PropertyChangeEvent& _rEvent ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
- {
- OUString sURL;
- _rEvent.NewValue >>= sURL;
- FastLoader* pCreatorThread = NULL;
-
- if ( m_aTypeCollection.needsJVM(sURL) )
- {
-#if HAVE_FEATURE_JAVA
- pCreatorThread = new FastLoader(m_xContext, FastLoader::E_JAVA);
-#endif
- }
- else if ( sURL.startsWithIgnoreAsciiCase("sdbc:calc:") )
- {
- pCreatorThread = new FastLoader(m_xContext, FastLoader::E_CALC);
- }
- if ( pCreatorThread )
- {
- pCreatorThread->createSuspended();
- pCreatorThread->setPriority(osl_Thread_PriorityBelowNormal);
- pCreatorThread->resume();
- }
- }
- // XEventListener
- virtual void SAL_CALL disposing( const lang::EventObject& /*_rSource*/ ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
- {
- }
- };
- }
sal_Char const sXML_np__db[] = "_db";
sal_Char const sXML_np___db[] = "__db";
@@ -483,8 +329,6 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
uno::Reference<sdb::XOfficeDatabaseDocument> xOfficeDoc(GetModel(),UNO_QUERY_THROW);
m_xDataSource.set(xOfficeDoc->getDataSource(),UNO_QUERY_THROW);
- uno::Reference<beans::XPropertyChangeListener> xListener = new DatasourceURLListener( GetComponentContext());
- m_xDataSource->addPropertyChangeListener(PROPERTY_URL,xListener);
uno::Reference< XNumberFormatsSupplier > xNum(m_xDataSource->getPropertyValue(PROPERTY_NUMBERFORMATSSUPPLIER),UNO_QUERY);
SetNumberFormatsSupplier(xNum);