diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-09-04 19:58:39 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-06 19:33:28 +0000 |
commit | 508d1bf7dfa1be99e3fc8d57eb780150af53290e (patch) | |
tree | 4b24d201eca2ac7602ee472e3f15c4b3d2ee8b0c /connectivity | |
parent | 5c4cecb7ee3c910d739dee0701a4f54b06109cf5 (diff) |
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@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/Connection.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Driver.cxx | 18 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Driver.hxx | 4 |
3 files changed, 16 insertions, 8 deletions
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 0d531235b717..d719b853cab9 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 5e9f04ba416e..4480bb9be4dc 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 096346817f78..31c93c65142b 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 |