[Libreoffice-commits] core.git: connectivity/source
Andrzej J.R. Hunt
andrzej at ahunt.org
Fri Sep 6 12:33:47 PDT 2013
connectivity/source/drivers/firebird/Connection.cxx | 2 +-
connectivity/source/drivers/firebird/Driver.cxx | 18 +++++++++++-------
connectivity/source/drivers/firebird/Driver.hxx | 4 ++++
3 files changed, 16 insertions(+), 8 deletions(-)
New commits:
commit 508d1bf7dfa1be99e3fc8d57eb780150af53290e
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Wed Sep 4 19:58:39 2013 +0100
Use the user specific tmp directory for firebird.
osl::FileBase::getTempDirURL uses the general tmp directory which
can be the system wide directory (i.e. /tmp). This can lead to conflicts
e.g. if we have multiple instances each trying to create /tmp/firebird.
Instead we use ::utl::TempFile which uses a user-specific directory (as a
subdirectory of what osl::FileBase::getTempDirURL provides), in which we
can have the FIREBIRD_TMP and FIREBIRD_LOCK directories.
Change-Id: Ic868f12b0a56900eac75f2418986193dd5fe0f10
Reviewed-on: https://gerrit.libreoffice.org/5797
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx
index 0d53123..d719b85 100644
--- a/connectivity/source/drivers/firebird/Connection.cxx
+++ b/connectivity/source/drivers/firebird/Connection.cxx
@@ -149,7 +149,7 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
bIsNewDatabase = !m_xEmbeddedStorage->hasElements();
- m_sURL = utl::TempFile::CreateTempName() + ".fdb";
+ m_sURL = utl::TempFile::CreateTempName();
SAL_INFO("connectivity.firebird", "Temporary .fdb location: "
<< OUStringToOString(m_sURL,RTL_TEXTENCODING_UTF8 ).getStr());
diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx
index 5e9f04b..4480bb9 100644
--- a/connectivity/source/drivers/firebird/Driver.cxx
+++ b/connectivity/source/drivers/firebird/Driver.cxx
@@ -27,7 +27,6 @@
#include <comphelper/processfactory.hxx>
#include <osl/process.h>
-#include <osl/file.hxx>
using namespace com::sun::star;
using namespace com::sun::star::uno;
@@ -60,16 +59,21 @@ const OUString FirebirdDriver::our_sFirebirdLockVar("FIREBIRD_LOCK");
FirebirdDriver::FirebirdDriver()
: ODriver_BASE(m_aMutex)
+ , m_firebirdTMPDirectory(NULL, true)
+ , m_firebirdLockDirectory(NULL, true)
{
- OUString sTmpDirURL, sTmpDirPath;
- ::osl::FileBase::getTempDirURL(sTmpDirURL);
- ::osl::FileBase::getSystemPathFromFileURL(sTmpDirURL, sTmpDirPath);
+ m_firebirdTMPDirectory.EnableKillingFile();
+ m_firebirdLockDirectory.EnableKillingFile();
+
+ // ::utl::TempFile uses a unique temporary directory (subdirectory of
+ // /tmp or other user specific tmp directory) per instance in which
+ // we can create directories for firebird at will.
// Overrides firebird's default of /tmp or c:\temp
- osl_setEnvironment(our_sFirebirdTmpVar.pData, sTmpDirPath.pData);
+ osl_setEnvironment(our_sFirebirdTmpVar.pData, m_firebirdTMPDirectory.GetFileName().pData);
+
// Overrides firebird's default of /tmp/firebird or c:\temp\firebird
- sTmpDirPath += "/firebird";
- osl_setEnvironment(our_sFirebirdLockVar.pData, sTmpDirPath.pData);
+ osl_setEnvironment(our_sFirebirdLockVar.pData, m_firebirdLockDirectory.GetFileName().pData);
}
void FirebirdDriver::disposing()
diff --git a/connectivity/source/drivers/firebird/Driver.hxx b/connectivity/source/drivers/firebird/Driver.hxx
index 0963468..31c93c6 100644
--- a/connectivity/source/drivers/firebird/Driver.hxx
+++ b/connectivity/source/drivers/firebird/Driver.hxx
@@ -26,6 +26,7 @@
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
#include <cppuhelper/compbase3.hxx>
+#include <unotools/tempfile.hxx>
namespace connectivity
{
@@ -48,6 +49,9 @@ namespace connectivity
static const ::rtl::OUString our_sFirebirdTmpVar;
static const ::rtl::OUString our_sFirebirdLockVar;
+ ::utl::TempFile m_firebirdTMPDirectory;
+ ::utl::TempFile m_firebirdLockDirectory;
+
protected:
::osl::Mutex m_aMutex; // mutex is need to control member access
OWeakRefArray m_xConnections; // vector containing a list
More information about the Libreoffice-commits
mailing list