Kaydet (Commit) 137131b1 authored tarafından Michael Stahl's avatar Michael Stahl

connectivity: firebird: fix Connection leak in OStatementCommonBase

bin/refcount_leak.py was very helpful here.

Change-Id: I61dc57408cf1533f733c08b701884851ec6afb8d
üst 666ec98b
...@@ -152,7 +152,7 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData() ...@@ -152,7 +152,7 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData()
ensurePrepared(); ensurePrepared();
if(!m_xMetaData.is()) if(!m_xMetaData.is())
m_xMetaData = new OResultSetMetaData(m_pConnection, m_pOutSqlda); m_xMetaData = new OResultSetMetaData(m_pConnection.get(), m_pOutSqlda);
return m_xMetaData; return m_xMetaData;
} }
...@@ -239,7 +239,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection() ...@@ -239,7 +239,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection()
MutexGuard aGuard( m_aMutex ); MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
return Reference< XConnection >(m_pConnection); return Reference<XConnection>(m_pConnection.get());
} }
sal_Bool SAL_CALL OPreparedStatement::execute() sal_Bool SAL_CALL OPreparedStatement::execute()
...@@ -282,7 +282,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute() ...@@ -282,7 +282,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
evaluateStatusVector(m_statusVector, "isc_dsql_execute", *this); evaluateStatusVector(m_statusVector, "isc_dsql_execute", *this);
} }
m_xResultSet = new OResultSet(m_pConnection, m_xResultSet = new OResultSet(m_pConnection.get(),
m_aMutex, m_aMutex,
uno::Reference< XInterface >(*this), uno::Reference< XInterface >(*this),
m_aStatementHandle, m_aStatementHandle,
......
...@@ -79,6 +79,7 @@ namespace connectivity ...@@ -79,6 +79,7 @@ namespace connectivity
sal_Int32 m_nResultSetConcurrency; sal_Int32 m_nResultSetConcurrency;
protected: protected:
// Connection kept alive by m_xStatement
Connection* m_pConnection; Connection* m_pConnection;
::osl::Mutex& m_rMutex; ::osl::Mutex& m_rMutex;
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& m_xStatement; const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& m_xStatement;
......
...@@ -125,7 +125,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s ...@@ -125,7 +125,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
if (aErr) if (aErr)
SAL_WARN("connectivity.firebird", "isc_dsql_execute failed"); SAL_WARN("connectivity.firebird", "isc_dsql_execute failed");
m_xResultSet = new OResultSet(m_pConnection, m_xResultSet = new OResultSet(m_pConnection.get(),
m_aMutex, m_aMutex,
uno::Reference< XInterface >(*this), uno::Reference< XInterface >(*this),
m_aStatementHandle, m_aStatementHandle,
...@@ -162,7 +162,7 @@ uno::Reference< XConnection > SAL_CALL OStatement::getConnection() ...@@ -162,7 +162,7 @@ uno::Reference< XConnection > SAL_CALL OStatement::getConnection()
MutexGuard aGuard(m_aMutex); MutexGuard aGuard(m_aMutex);
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
return uno::Reference< XConnection >(m_pConnection); return uno::Reference<XConnection>(m_pConnection.get());
} }
Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException, std::exception) Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
......
...@@ -51,7 +51,6 @@ OStatementCommonBase::OStatementCommonBase(Connection* _pConnection) ...@@ -51,7 +51,6 @@ OStatementCommonBase::OStatementCommonBase(Connection* _pConnection)
m_aStatementHandle( 0 ), m_aStatementHandle( 0 ),
rBHelper(OStatementCommonBase_Base::rBHelper) rBHelper(OStatementCommonBase_Base::rBHelper)
{ {
m_pConnection->acquire();
} }
OStatementCommonBase::~OStatementCommonBase() OStatementCommonBase::~OStatementCommonBase()
......
...@@ -60,7 +60,7 @@ namespace connectivity ...@@ -60,7 +60,7 @@ namespace connectivity
::std::list< ::rtl::OUString> m_aBatchList; ::std::list< ::rtl::OUString> m_aBatchList;
Connection* m_pConnection; ::rtl::Reference<Connection> m_pConnection;
ISC_STATUS_ARRAY m_statusVector; ISC_STATUS_ARRAY m_statusVector;
isc_stmt_handle m_aStatementHandle; isc_stmt_handle m_aStatementHandle;
...@@ -136,9 +136,6 @@ namespace connectivity ...@@ -136,9 +136,6 @@ namespace connectivity
// XCloseable // XCloseable
virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// other methods
Connection* getOwnConnection() const { return m_pConnection;}
}; };
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment