From: <asf...@us...> - 2011-05-07 19:52:52
|
Revision: 52892 http://firebird.svn.sourceforge.net/firebird/?rev=52892&view=rev Author: asfernandes Date: 2011-05-07 19:52:44 +0000 (Sat, 07 May 2011) Log Message: ----------- Integrate IAttachment and ITransaction in the external engines API. Modified Paths: -------------- firebird/trunk/builds/posix/firebird.vers firebird/trunk/builds/win32/defs/firebird.def firebird/trunk/examples/udr/UdrCppExample.cpp firebird/trunk/src/gpre/boot/gpre_meta_boot.cpp firebird/trunk/src/include/FirebirdApi.h firebird/trunk/src/include/FirebirdExternalApi.h firebird/trunk/src/include/FirebirdUdrCpp.h firebird/trunk/src/include/Interface.h firebird/trunk/src/include/ProviderInterface.h firebird/trunk/src/jrd/Attachment.cpp firebird/trunk/src/jrd/Attachment.h firebird/trunk/src/jrd/EngineInterface.h firebird/trunk/src/jrd/ExtEngineManager.cpp firebird/trunk/src/jrd/ExtEngineManager.h firebird/trunk/src/jrd/extds/InternalDS.cpp firebird/trunk/src/jrd/ibase.h firebird/trunk/src/jrd/jrd.cpp firebird/trunk/src/jrd/tra.h firebird/trunk/src/plugins/udr_engine/UdrEngine.cpp firebird/trunk/src/remote/client/interface.cpp firebird/trunk/src/yvalve/MasterImplementation.cpp firebird/trunk/src/yvalve/MasterImplementation.h firebird/trunk/src/yvalve/PluginManager.cpp firebird/trunk/src/yvalve/why.cpp firebird/trunk/src/yvalve/why_proto.h Modified: firebird/trunk/builds/posix/firebird.vers =================================================================== --- firebird/trunk/builds/posix/firebird.vers 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/builds/posix/firebird.vers 2011-05-07 19:52:44 UTC (rev 52892) @@ -342,6 +342,9 @@ fb_get_master_interface +fb_get_database_handle +fb_get_transaction_handle + # Other misc functions isc_ftof Modified: firebird/trunk/builds/win32/defs/firebird.def =================================================================== --- firebird/trunk/builds/win32/defs/firebird.def 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/builds/win32/defs/firebird.def 2011-05-07 19:52:44 UTC (rev 52892) @@ -352,6 +352,8 @@ fb_ping fb_get_master_interface + fb_get_database_handle + fb_get_transaction_handle gds__trace gds__trace_raw Modified: firebird/trunk/examples/udr/UdrCppExample.cpp =================================================================== --- firebird/trunk/examples/udr/UdrCppExample.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/examples/udr/UdrCppExample.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -158,8 +158,6 @@ unsigned char* eveBuffer; unsigned char* eveResult; - // NOTE: isc_event_block leaks the two memory buffers allocated. - // You should manually construct the EPB if you care. int eveLen = funcEventBlock(&eveBuffer, &eveResult, 1, s); ISC_STATUS_ARRAY statusVector = {0}; @@ -173,6 +171,9 @@ statusVector); funcEventCounts(&counter, eveLen, eveBuffer, eveResult); + isc_free((char*) eveBuffer); + isc_free((char*) eveResult); + // returns the counter result->setInt(ThrowError(), counter); } Modified: firebird/trunk/src/gpre/boot/gpre_meta_boot.cpp =================================================================== --- firebird/trunk/src/gpre/boot/gpre_meta_boot.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/gpre/boot/gpre_meta_boot.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -720,6 +720,18 @@ fb_assert(false); return NULL; } + + virtual IAttachment* registerAttachment(IProvider* /*provider*/, IAttachment* /*attachment*/) + { + fb_assert(false); + return NULL; + } + + virtual ITransaction* registerTransaction(IAttachment* /*attachment*/, ITransaction* /*transaction*/) + { + fb_assert(false); + return NULL; + } }; Modified: firebird/trunk/src/include/FirebirdApi.h =================================================================== --- firebird/trunk/src/include/FirebirdApi.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/include/FirebirdApi.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -106,25 +106,6 @@ }; -class Attachment : public Disposable -{ -public: - // Get an ISC compatible attachment handle. - virtual Handle FB_CALL getHandle(Error* error) const = 0; - - virtual const char* FB_CALL getUserName() const = 0; - virtual const char* FB_CALL getDatabaseName() const = 0; -}; - - -class Transaction -{ -public: - // Get an ISC compatible transaction handle. - virtual Handle FB_CALL getHandle(Error* error) const = 0; -}; - - // Represents a parameter or column. class Value { Modified: firebird/trunk/src/include/FirebirdExternalApi.h =================================================================== --- firebird/trunk/src/include/FirebirdExternalApi.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/include/FirebirdExternalApi.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -35,6 +35,7 @@ #include "FirebirdApi.h" #include "FirebirdPluginApi.h" +#include "ProviderInterface.h" namespace Firebird { @@ -58,12 +59,15 @@ virtual ExternalEngine* FB_CALL getEngine(Error* error) = 0; // Gets the Attachment associated with this context. - virtual Attachment* FB_CALL getAttachment(Error* error) = 0; + virtual IAttachment* FB_CALL getAttachment(Error* error) = 0; // Obtained transaction is valid only before control is returned to the engine // or in ExternalResultSet::fetch calls of correspondent ExternalProcedure::open. - virtual Transaction* FB_CALL getTransaction(Error* error) = 0; + virtual ITransaction* FB_CALL getTransaction(Error* error) = 0; + virtual const char* FB_CALL getUserName() = 0; + virtual const char* FB_CALL getDatabaseName() = 0; + // Get user attachment character set. virtual const Utf8* FB_CALL getClientCharSet() = 0; Modified: firebird/trunk/src/include/FirebirdUdrCpp.h =================================================================== --- firebird/trunk/src/include/FirebirdUdrCpp.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/include/FirebirdUdrCpp.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -438,14 +438,20 @@ public: static isc_db_handle getIscDbHandle(ExternalContext* context) { - Attachment* att = context->getAttachment(ThrowError()); - return att->getHandle(ThrowError()); + ISC_STATUS_ARRAY status = {0}; + isc_db_handle handle = 0; + fb_get_database_handle(status, &handle, context->getAttachment(ThrowError())); + ThrowError::check(status); + return handle; } static isc_tr_handle getIscTrHandle(ExternalContext* context) { - Transaction* tra = context->getTransaction(ThrowError()); - return tra->getHandle(ThrowError()); + ISC_STATUS_ARRAY status = {0}; + isc_tr_handle handle = 0; + fb_get_transaction_handle(status, &handle, context->getTransaction(ThrowError())); + ThrowError::check(status); + return handle; } static void* getEntryPoint(ExternalContext* /*context*/, const char* entryPoint) Modified: firebird/trunk/src/include/Interface.h =================================================================== --- firebird/trunk/src/include/Interface.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/include/Interface.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -77,6 +77,8 @@ class IProvider; class IPluginManager; class ITimerControl; +class IAttachment; +class ITransaction; // Master interface is used to access almost all other interfaces. class IMaster : public IDisposable @@ -91,6 +93,8 @@ virtual int FB_CARG upgradeInterface(IInterface* toUpgrade, int desiredVersion, void* missingFunctionClass) = 0; virtual const char* FB_CARG circularAlloc(const char* s, size_t len, intptr_t thr) = 0; virtual ITimerControl* FB_CARG getTimerControl() = 0; + virtual IAttachment* registerAttachment(IProvider* provider, IAttachment* attachment) = 0; + virtual ITransaction* registerTransaction(IAttachment* attachment, ITransaction* transaction) = 0; }; } // namespace Firebird Modified: firebird/trunk/src/include/ProviderInterface.h =================================================================== --- firebird/trunk/src/include/ProviderInterface.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/include/ProviderInterface.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -178,8 +178,7 @@ unsigned int bufferLength, unsigned char* buffer) = 0; // virtual ITransaction* FB_CARG startTransaction(IStatus* status, unsigned int tpbLength, const unsigned char* tpb) = 0; // second form is tmp - not to rewrite external engines right now - virtual ITransaction* FB_CARG startTransaction(IStatus* status, unsigned int tpbLength, const unsigned char* tpb, - FB_API_HANDLE api) = 0; + virtual ITransaction* FB_CARG startTransaction(IStatus* status, unsigned int tpbLength, const unsigned char* tpb) = 0; virtual ITransaction* FB_CARG reconnectTransaction(IStatus* status, unsigned int length, const unsigned char* id) = 0; virtual IStatement* FB_CARG allocateStatement(IStatus* status) = 0; virtual IRequest* FB_CARG compileRequest(IStatus* status, unsigned int blrLength, const unsigned char* blr) = 0; @@ -230,10 +229,10 @@ class IProvider : public IPluginBase { public: - virtual void FB_CARG attachDatabase(IStatus* status, IAttachment** ptr, FB_API_HANDLE api, const char* fileName, - unsigned int dpbLength, const unsigned char* dpb) = 0; - virtual void FB_CARG createDatabase(IStatus* status, IAttachment** ptr, FB_API_HANDLE api, const char* fileName, - unsigned int dpbLength, const unsigned char* dpb) = 0; + virtual IAttachment* FB_CARG attachDatabase(IStatus* status, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb) = 0; + virtual IAttachment* FB_CARG createDatabase(IStatus* status, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb) = 0; virtual IService* FB_CARG attachServiceManager(IStatus* status, const char* service, unsigned int spbLength, const unsigned char* spb) = 0; //virtual ITransaction* FB_CARG startTransaction(IStatus* status, unsigned int count, ...) = 0; Modified: firebird/trunk/src/jrd/Attachment.cpp =================================================================== --- firebird/trunk/src/jrd/Attachment.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/jrd/Attachment.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -48,13 +48,13 @@ // static method -Jrd::Attachment* Jrd::Attachment::create(Database* dbb, FB_API_HANDLE publicHandle) +Jrd::Attachment* Jrd::Attachment::create(Database* dbb) { MemoryPool* const pool = dbb->createPool(); try { - Attachment* const attachment = FB_NEW(*pool) Attachment(pool, dbb, publicHandle); + Attachment* const attachment = FB_NEW(*pool) Attachment(pool, dbb); pool->setStatsGroup(attachment->att_memory_stats); return attachment; } @@ -135,11 +135,10 @@ } -Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb, FB_API_HANDLE publicHandle) +Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb) : att_pool(pool), att_memory_stats(&dbb->dbb_memory_stats), att_database(dbb), - att_public_handle(publicHandle), att_requests(*pool), att_lock_owner_id(Database::getLockOwnerId()), att_backup_state_counter(0), @@ -157,7 +156,8 @@ att_ext_connection(NULL), att_ext_call_depth(0), att_trace_manager(FB_NEW(*att_pool) TraceManager(this)), - att_interface(NULL) + att_interface(NULL), + att_public_interface(NULL) { } Modified: firebird/trunk/src/jrd/Attachment.h =================================================================== --- firebird/trunk/src/jrd/Attachment.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/jrd/Attachment.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -121,14 +121,13 @@ class Attachment : public pool_alloc<type_att> { public: - static Attachment* create(Database* dbb, FB_API_HANDLE publicHandle); + static Attachment* create(Database* dbb); static void destroy(Attachment* const attachment); MemoryPool* const att_pool; // Memory pool Firebird::MemoryStats att_memory_stats; Database* att_database; // Parent database block - FB_API_HANDLE att_public_handle; // Public handle Attachment* att_next; // Next attachment to database UserId* att_user; // User identification jrd_tra* att_transactions; // Transactions belonging to attachment @@ -177,6 +176,7 @@ TraceManager* att_trace_manager; // Trace API manager JAttachment* att_interface; + Firebird::IAttachment* att_public_interface; bool locksmith() const; jrd_tra* getSysTransaction(); @@ -216,7 +216,7 @@ void backupStateReadUnLock(thread_db* tdbb); private: - Attachment(MemoryPool* pool, Database* dbb, FB_API_HANDLE publicHandle); + Attachment(MemoryPool* pool, Database* dbb); ~Attachment(); }; Modified: firebird/trunk/src/jrd/EngineInterface.h =================================================================== --- firebird/trunk/src/jrd/EngineInterface.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/jrd/EngineInterface.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -256,8 +256,8 @@ virtual void FB_CARG getInfo(Firebird::IStatus* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer); - virtual JTransaction* FB_CARG startTransaction(Firebird::IStatus* status, unsigned int tpbLength, const unsigned char* tpb, - FB_API_HANDLE api); + virtual JTransaction* FB_CARG startTransaction(Firebird::IStatus* status, + unsigned int tpbLength, const unsigned char* tpb); virtual JTransaction* FB_CARG reconnectTransaction(Firebird::IStatus* status, unsigned int length, const unsigned char* id); virtual JStatement* FB_CARG allocateStatement(Firebird::IStatus* status); virtual JRequest* FB_CARG compileRequest(Firebird::IStatus* status, unsigned int blr_length, const unsigned char* blr); @@ -353,10 +353,10 @@ } // IProvider implementation - virtual void FB_CARG attachDatabase(Firebird::IStatus* status, Firebird::IAttachment** ptr, - FB_API_HANDLE api, const char* fileName, unsigned int dpbLength, const unsigned char* dpb); - virtual void FB_CARG createDatabase(Firebird::IStatus* status, Firebird::IAttachment** ptr, - FB_API_HANDLE api, const char* fileName, unsigned int dpbLength, const unsigned char* dpb); + virtual JAttachment* FB_CARG attachDatabase(Firebird::IStatus* status, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb); + virtual JAttachment* FB_CARG createDatabase(Firebird::IStatus* status, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb); virtual JService* FB_CARG attachServiceManager(Firebird::IStatus* status, const char* service, unsigned int spbLength, const unsigned char* spb); //virtual ITransaction* startTransaction(Firebird::IStatus* status, unsigned int count, ...); Modified: firebird/trunk/src/jrd/ExtEngineManager.cpp =================================================================== --- firebird/trunk/src/jrd/ExtEngineManager.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/jrd/ExtEngineManager.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -60,40 +60,6 @@ namespace Jrd { -class ExtEngineManager::AttachmentImpl : public Firebird::Attachment -{ -public: - AttachmentImpl(ExternalContextImpl* aContext, Handle aHandle, Jrd::Attachment* aAttachment); - virtual ~AttachmentImpl(); - -public: - virtual void FB_CALL dispose(Error* error); - - virtual Handle FB_CALL getHandle(Error* error) const; - virtual const char* FB_CALL getUserName() const; - virtual const char* FB_CALL getDatabaseName() const; - -private: - ExternalContextImpl* context; - FB_API_HANDLE handle; - Jrd::Attachment* attachment; -}; - - -class ExtEngineManager::TransactionImpl : public Firebird::Transaction -{ -public: - TransactionImpl(Handle aHandle); - virtual ~TransactionImpl(); - -public: - virtual Handle FB_CALL getHandle(Error* error) const; - -private: - FB_API_HANDLE handle; -}; - - template <typename T> class ExtEngineManager::ContextManager { public: @@ -200,89 +166,18 @@ //--------------------- -ExtEngineManager::AttachmentImpl::AttachmentImpl(ExternalContextImpl* aContext, Handle aHandle, - Jrd::Attachment* aAttachment) - : context(aContext), - handle(aHandle), - attachment(aAttachment) -{ -} - -ExtEngineManager::AttachmentImpl::~AttachmentImpl() -{ - context->attachment.release(); - handle = 0; - dispose(LogError()); -} - -void FB_CALL ExtEngineManager::AttachmentImpl::dispose(Error* error) -{ - ISC_STATUS_ARRAY statusVector; - - if (handle) - { - if (isc_detach_database(statusVector, &handle) != 0) - { - ErrorImpl::statusVectorToError(statusVector, error); - return; - } - } - - context->attachment = NULL; -} - -Handle FB_CALL ExtEngineManager::AttachmentImpl::getHandle(Error* /*error*/) const -{ - return handle; -} - - -const char* FB_CALL ExtEngineManager::AttachmentImpl::getUserName() const -{ - return attachment->att_user->usr_user_name.c_str(); -} - - -const char* FB_CALL ExtEngineManager::AttachmentImpl::getDatabaseName() const -{ - return attachment->att_database->dbb_database_name.c_str(); -} - - -//--------------------- - - -ExtEngineManager::TransactionImpl::TransactionImpl(Handle aHandle) - : handle(aHandle) -{ -} - -ExtEngineManager::TransactionImpl::~TransactionImpl() -{ -} - -Handle FB_CALL ExtEngineManager::TransactionImpl::getHandle(Error* /*error*/) const -{ - return handle; -} - - -//--------------------- - - ExtEngineManager::ExternalContextImpl::ExternalContextImpl(thread_db* tdbb, ExternalEngine* aEngine) : engine(aEngine), internalAttachment(tdbb->getAttachment()), - miscInfo(*internalAttachment->att_pool), - traHandle(0) + internalTransaction(NULL), + externalAttachment(NULL), + externalTransaction(NULL), + miscInfo(*internalAttachment->att_pool) { //// TODO: admin rights - attHandle = internalAttachment->att_public_handle; clientCharSet = INTL_charset_lookup(tdbb, internalAttachment->att_client_charset)->getName(); - - setTransaction(tdbb); } ExtEngineManager::ExternalContextImpl::~ExternalContextImpl() @@ -292,21 +187,48 @@ void ExtEngineManager::ExternalContextImpl::releaseTransaction() { - if (traHandle) + if (externalTransaction) { - traHandle = 0; - transaction = NULL; + externalTransaction->release(); + externalTransaction = NULL; } + + if (externalAttachment) + { + externalAttachment->release(); + externalAttachment = NULL; + } + + internalTransaction = NULL; } void ExtEngineManager::ExternalContextImpl::setTransaction(thread_db* tdbb) { + jrd_tra* newTransaction = tdbb->getTransaction(); + + if (newTransaction == internalTransaction) + return; + releaseTransaction(); + fb_assert(!externalAttachment && !externalTransaction); - jrd_tra* tra = tdbb->getTransaction(); - traHandle = tra ? tra->tra_public_handle : 0; + MasterInterfacePtr master; - transaction = FB_NEW(*internalAttachment->att_pool) TransactionImpl(traHandle); + if (internalAttachment) + { + internalAttachment->att_interface->addRef(); + + externalAttachment = master->registerAttachment(currentProvider(), + internalAttachment->att_interface); + } + + if ((internalTransaction = newTransaction)) + { + internalTransaction->tra_interface->addRef(); + + externalTransaction = master->registerTransaction(externalAttachment, + internalTransaction->tra_interface); + } } ExternalEngine* ExtEngineManager::ExternalContextImpl::getEngine(Error* /*error*/) @@ -314,37 +236,37 @@ return engine; } -Firebird::Attachment* FB_CALL ExtEngineManager::ExternalContextImpl::getAttachment(Error* /*error*/) +Firebird::IAttachment* FB_CALL ExtEngineManager::ExternalContextImpl::getAttachment(Error* /*error*/) { - if (!this->attachment) - { - thread_db* tdbb = JRD_get_thread_data(); - attachment = FB_NEW(*internalAttachment->att_pool) AttachmentImpl(this, attHandle, - tdbb->getAttachment()); - } + return externalAttachment; +} - return attachment; +Firebird::ITransaction* FB_CALL ExtEngineManager::ExternalContextImpl::getTransaction(Error* /*error*/) +{ + return externalTransaction; } -Firebird::Transaction* FB_CALL ExtEngineManager::ExternalContextImpl::getTransaction(Error* /*error*/) +const char* FB_CALL ExtEngineManager::ExternalContextImpl::getUserName() { - return transaction; + return internalAttachment->att_user->usr_user_name.c_str(); } +const char* FB_CALL ExtEngineManager::ExternalContextImpl::getDatabaseName() +{ + return internalAttachment->att_database->dbb_database_name.c_str(); +} const Utf8* FB_CALL ExtEngineManager::ExternalContextImpl::getClientCharSet() { return clientCharSet.c_str(); } - int FB_CALL ExtEngineManager::ExternalContextImpl::obtainInfoCode() { static AtomicCounter counter; return ++counter; } - void* FB_CALL ExtEngineManager::ExternalContextImpl::getInfo(int code) { void* value = NULL; @@ -352,7 +274,6 @@ return value; } - void* FB_CALL ExtEngineManager::ExternalContextImpl::setInfo(int code, void* value) { void* oldValue = getInfo(code); @@ -705,8 +626,11 @@ if (attInfo) { - ContextManager<ExternalFunction> ctxManager(tdbb, attInfo, attInfo->adminCharSet); - engine->closeAttachment(LogError(), attInfo->context); + { // scope + ContextManager<ExternalFunction> ctxManager(tdbb, attInfo, attInfo->adminCharSet); + engine->closeAttachment(LogError(), attInfo->context); + } + delete attInfo; } } Modified: firebird/trunk/src/jrd/ExtEngineManager.h =================================================================== --- firebird/trunk/src/jrd/ExtEngineManager.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/jrd/ExtEngineManager.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -41,6 +41,7 @@ class thread_db; class jrd_prc; +class jrd_tra; class Attachment; class Database; class Format; @@ -72,8 +73,10 @@ void setTransaction(thread_db* tdbb); virtual Firebird::ExternalEngine* FB_CALL getEngine(Firebird::Error* error); - virtual Firebird::Attachment* FB_CALL getAttachment(Firebird::Error* error); - virtual Firebird::Transaction* FB_CALL getTransaction(Firebird::Error* error); + virtual Firebird::IAttachment* FB_CALL getAttachment(Firebird::Error* error); + virtual Firebird::ITransaction* FB_CALL getTransaction(Firebird::Error* error); + virtual const char* FB_CALL getUserName(); + virtual const char* FB_CALL getDatabaseName(); virtual const Firebird::Utf8* FB_CALL getClientCharSet(); virtual int FB_CALL obtainInfoCode(); virtual void* FB_CALL getInfo(int code); @@ -82,12 +85,11 @@ private: Firebird::ExternalEngine* engine; Attachment* internalAttachment; + jrd_tra* internalTransaction; + Firebird::IAttachment* externalAttachment; + Firebird::ITransaction* externalTransaction; Firebird::GenericMap<Firebird::NonPooled<int, void*> > miscInfo; - FB_API_HANDLE traHandle; - FB_API_HANDLE attHandle; Firebird::MetaName clientCharSet; - Firebird::AutoPtr<AttachmentImpl> attachment; - Firebird::AutoPtr<TransactionImpl> transaction; }; struct EngineAttachment Modified: firebird/trunk/src/jrd/extds/InternalDS.cpp =================================================================== --- firebird/trunk/src/jrd/extds/InternalDS.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/jrd/extds/InternalDS.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -163,7 +163,7 @@ { EngineCallbackGuard guard(tdbb, *this); - currentProvider()->attachDatabase(&status, &a, 0, m_dbName.c_str(), + a = currentProvider()->attachDatabase(&status, m_dbName.c_str(), m_dpb.getBufferLength(), m_dpb.getBuffer()); } @@ -277,8 +277,7 @@ EngineCallbackGuard guard(tdbb, *this); IntStatus s(status); - m_transaction = att->startTransaction(&s, tpb.getBufferLength(), tpb.getBuffer(), 0); - //// FIXME: public_handle + m_transaction = att->startTransaction(&s, tpb.getBufferLength(), tpb.getBuffer()); } } Modified: firebird/trunk/src/jrd/ibase.h =================================================================== --- firebird/trunk/src/jrd/ibase.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/jrd/ibase.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -1154,6 +1154,13 @@ ISC_STATUS ISC_EXPORT fb_ping(ISC_STATUS*, isc_db_handle*); +/***********************/ +/* Object interface */ +/***********************/ + +ISC_STATUS ISC_EXPORT fb_get_database_handle(ISC_STATUS*, isc_db_handle*, void*); +ISC_STATUS ISC_EXPORT fb_get_transaction_handle(ISC_STATUS*, isc_tr_handle*, void*); + /********************************/ /* Client information functions */ /********************************/ Modified: firebird/trunk/src/jrd/jrd.cpp =================================================================== --- firebird/trunk/src/jrd/jrd.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/jrd/jrd.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -788,8 +788,7 @@ static Database* init(thread_db*, const PathName&, RefPtr<Config>, bool); static void prepare_tra(thread_db*, jrd_tra*, USHORT, const UCHAR*); static void start_transaction(thread_db* tdbb, bool transliterate, jrd_tra** tra_handle, - Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb, - FB_API_HANDLE public_handle = 0); + Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb); static void release_attachment(thread_db*, Jrd::Attachment*); static void rollback(thread_db*, jrd_tra*, const bool); static void shutdown_database(Database*, const bool); @@ -1076,12 +1075,8 @@ namespace Jrd { -void JProvider::attachDatabase(IStatus* user_status, - Firebird::IAttachment** handle, - FB_API_HANDLE public_handle, - const char* filename, - unsigned int dpb_length, - const unsigned char* dpb) +JAttachment* FB_CARG JProvider::attachDatabase(IStatus* user_status, const char* filename, + unsigned int dpb_length, const unsigned char* dpb) { /************************************** * @@ -1094,8 +1089,6 @@ * sullied by user data. * **************************************/ - *handle = NULL; - try { ThreadContextHolder tdbb(user_status); @@ -1223,7 +1216,7 @@ } } - attachment = Jrd::Attachment::create(dbb, public_handle); + attachment = Jrd::Attachment::create(dbb); tdbb->setAttachment(attachment); attachment->att_filename = is_alias ? file_name : expanded_name; attachment->att_network_protocol = options.dpb_network_protocol; @@ -1662,7 +1655,6 @@ attachment->att_interface = jAtt; MutexLockGuard guard(*(jAtt->getMutex())); - *handle = jAtt; if (attachment->att_trace_manager->needs(TRACE_EVENT_ATTACH)) { @@ -1706,7 +1698,6 @@ } catch (const Exception&) { - *handle = NULL; attachment->att_flags = save_flags; if (!(dbb->dbb_flags & DBB_bugcheck) && transaction) TRA_rollback(tdbb, transaction, false, false); @@ -1717,7 +1708,7 @@ // guardDatabases.leave(); jAtt->addRef(); - return; + return jAtt; } // try catch (const Exception& ex) { @@ -1733,7 +1724,8 @@ { ex.stuffException(user_status); } - *handle = NULL; + + return NULL; } @@ -2161,9 +2153,8 @@ } -void JProvider::createDatabase(IStatus* user_status, Firebird::IAttachment** handle, - FB_API_HANDLE public_handle, const char* filename, unsigned int dpb_length, - const unsigned char* dpb) +JAttachment* FB_CARG JProvider::createDatabase(IStatus* user_status, const char* filename, + unsigned int dpb_length, const unsigned char* dpb) { /************************************** * @@ -2175,8 +2166,6 @@ * Create a nice, squeeky clean database, uncorrupted by user data. * **************************************/ - *handle = NULL; - try { ThreadContextHolder tdbb(user_status); @@ -2277,7 +2266,7 @@ dbb->dbb_encrypt_key = options.dpb_key; } - attachment = Jrd::Attachment::create(dbb, public_handle); + attachment = Jrd::Attachment::create(dbb); tdbb->setAttachment(attachment); attachment->att_filename = is_alias ? file_name : expanded_name; attachment->att_network_protocol = options.dpb_network_protocol; @@ -2348,7 +2337,7 @@ { if (options.dpb_overwrite) { - attachDatabase(user_status, handle, public_handle, filename, dpb_length, dpb); + JAttachment* attachment2 = attachDatabase(user_status, filename, dpb_length, dpb); if (user_status->get()[1] == isc_adm_task_denied) { throw; @@ -2356,10 +2345,10 @@ bool allow_overwrite = false; - if (*handle) + if (attachment2) { - allow_overwrite = reinterpret_cast<Attachment*>(*handle)->att_user->locksmith(); - (*handle)->detach(user_status); + allow_overwrite = attachment2->getHandle()->att_user->locksmith(); + attachment2->detach(user_status); } else { @@ -2506,9 +2495,8 @@ JAttachment* jAtt = new JAttachment(attachment); jAtt->addRef(); attachment->att_interface = jAtt; - *handle = jAtt; - return; + return jAtt; } // try catch (const Exception& ex) { @@ -2525,7 +2513,7 @@ ex.stuffException(user_status); } - *handle = NULL; + return NULL; } @@ -3910,7 +3898,7 @@ JTransaction* JAttachment::startTransaction(IStatus* user_status, - unsigned int tpbLength, const unsigned char* tpb, FB_API_HANDLE public_handle) + unsigned int tpbLength, const unsigned char* tpb) { /************************************** * @@ -3929,7 +3917,7 @@ EngineContextHolder tdbb(user_status, this); check_database(tdbb); - start_transaction(tdbb, true, &tra, getHandle(), tpbLength, tpb, public_handle); + start_transaction(tdbb, true, &tra, getHandle(), tpbLength, tpb); } catch (const Exception& ex) { @@ -7147,8 +7135,7 @@ static void start_transaction(thread_db* tdbb, bool transliterate, jrd_tra** tra_handle, - Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb, - FB_API_HANDLE public_handle) + Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb) { /************************************** * @@ -7172,7 +7159,6 @@ { jrd_tra* transaction = TRA_start(tdbb, tpb_length, tpb); - transaction->tra_public_handle = public_handle; transaction->tra_sibling = NULL; *tra_handle = transaction; @@ -7318,6 +7304,7 @@ } +#if 0 namespace { typedef Array<FB_API_HANDLE> PingQueue; @@ -7336,6 +7323,7 @@ return 0; } } // namespace +#endif void JRD_shutdown_attachments(const Database* dbb) @@ -7352,6 +7340,7 @@ **************************************/ fb_assert(dbb); +#if 0 //// FIXME: try { MemoryPool& pool = *getDefaultMemoryPool(); @@ -7370,6 +7359,7 @@ } catch (const Exception&) {} // no-op +#endif } Modified: firebird/trunk/src/jrd/tra.h =================================================================== --- firebird/trunk/src/jrd/tra.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/jrd/tra.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -161,6 +161,7 @@ tra_transactions(*p), tra_sorts(*p), tra_interface(NULL), + tra_public_interface(NULL), tra_blob_space(NULL), tra_undo_space(NULL), tra_undo_record(NULL), @@ -262,6 +263,7 @@ EDS::Transaction *tra_ext_common; //Transaction *tra_ext_two_phase; JTransaction* tra_interface; + Firebird::ITransaction* tra_public_interface; private: TempSpace* tra_blob_space; // temp blob storage Modified: firebird/trunk/src/plugins/udr_engine/UdrEngine.cpp =================================================================== --- firebird/trunk/src/plugins/udr_engine/UdrEngine.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/plugins/udr_engine/UdrEngine.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -577,12 +577,7 @@ PathName path; PathUtils::concatPath(path, *i, *moduleName); - ModuleLoader::Module* module = ModuleLoader::loadModule(path); - if (!module) - { - ModuleLoader::doctorModuleExtension(path); - module = ModuleLoader::loadModule(path); - } + ModuleLoader::Module* module = ModuleLoader::fixAndLoadModule(path); if (module) { Modified: firebird/trunk/src/remote/client/interface.cpp =================================================================== --- firebird/trunk/src/remote/client/interface.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/remote/client/interface.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -354,8 +354,8 @@ unsigned int bufferLength, unsigned char* buffer); // virtual Firebird::ITransaction* startTransaction(IStatus* status, unsigned int tpbLength, const unsigned char* tpb); // second form is tmp - not to rewrite external engines right now - virtual Firebird::ITransaction* FB_CARG startTransaction(IStatus* status, unsigned int tpbLength, const unsigned char* tpb, - FB_API_HANDLE api); + virtual Firebird::ITransaction* FB_CARG startTransaction(IStatus* status, + unsigned int tpbLength, const unsigned char* tpb); virtual Firebird::ITransaction* FB_CARG reconnectTransaction(IStatus* status, unsigned int length, const unsigned char* id); virtual Firebird::IStatement* FB_CARG allocateStatement(IStatus* status); virtual Firebird::IRequest* FB_CARG compileRequest(IStatus* status, unsigned int blr_length, const unsigned char* blr); @@ -460,10 +460,10 @@ } // IProvider implementation - virtual void FB_CARG attachDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE api, const char* fileName, - unsigned int dpbLength, const unsigned char* dpb); - virtual void FB_CARG createDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE api, const char* fileName, - unsigned int dpbLength, const unsigned char* dpb); + virtual IAttachment* FB_CARG attachDatabase(IStatus* status, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb); + virtual IAttachment* FB_CARG createDatabase(IStatus* status, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb); virtual Firebird::IService* FB_CARG attachServiceManager(IStatus* status, const char* service, unsigned int spbLength, const unsigned char* spb); //virtual Firebird::ITransaction* startTransaction(IStatus* status, unsigned int count, ...); @@ -502,10 +502,10 @@ } // IProvider implementation - virtual void FB_CARG attachDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE api, const char* fileName, - unsigned int dpbLength, const unsigned char* dpb); - virtual void FB_CARG createDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE api, const char* fileName, - unsigned int dpbLength, const unsigned char* dpb); + virtual IAttachment* FB_CARG attachDatabase(IStatus* status, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb); + virtual IAttachment* FB_CARG createDatabase(IStatus* status, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb); virtual Firebird::IService* FB_CARG attachServiceManager(IStatus* status, const char* service, unsigned int spbLength, const unsigned char* spb); }; @@ -669,8 +669,8 @@ } -void Provider::attachDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE /*public_handle*/, - const char* filename, unsigned int dpb_length, const unsigned char* dpb) +IAttachment* Provider::attachDatabase(IStatus* status, const char* filename, + unsigned int dpb_length, const unsigned char* dpb) { /************************************** * @@ -683,12 +683,12 @@ * **************************************/ - *ptr = attach(status, filename, dpb_length, dpb, false); + return attach(status, filename, dpb_length, dpb, false); } -void Loopback::attachDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE /*public_handle*/, - const char* filename, unsigned int dpb_length, const unsigned char* dpb) +IAttachment* Loopback::attachDatabase(IStatus* status, const char* filename, + unsigned int dpb_length, const unsigned char* dpb) { /************************************** * @@ -701,7 +701,7 @@ * **************************************/ - *ptr = attach(status, filename, dpb_length, dpb, true); + return attach(status, filename, dpb_length, dpb, true); } @@ -1154,8 +1154,8 @@ } -void Provider::createDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE /*public_handle*/, - const char* fileName, unsigned int dpbLength, const unsigned char* dpb) +IAttachment* Provider::createDatabase(IStatus* status, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb) { /************************************** * @@ -1168,12 +1168,12 @@ * **************************************/ - *ptr = create(status, fileName, dpbLength, dpb, false); + return create(status, fileName, dpbLength, dpb, false); } -void Loopback::createDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE /*public_handle*/, - const char* fileName, unsigned int dpbLength, const unsigned char* dpb) +IAttachment* Loopback::createDatabase(IStatus* status, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb) { /************************************** * @@ -1186,7 +1186,7 @@ * **************************************/ - *ptr = create(status, fileName, dpbLength, dpb, true); + return create(status, fileName, dpbLength, dpb, true); } @@ -4338,9 +4338,8 @@ } -Firebird::ITransaction* Attachment::startTransaction(IStatus* status, - unsigned int tpbLength, const unsigned char* tpb, - FB_API_HANDLE /*api*/) +Firebird::ITransaction* Attachment::startTransaction(IStatus* status, unsigned int tpbLength, + const unsigned char* tpb) { /************************************** * Modified: firebird/trunk/src/yvalve/MasterImplementation.cpp =================================================================== --- firebird/trunk/src/yvalve/MasterImplementation.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/yvalve/MasterImplementation.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -31,7 +31,6 @@ #include "Timer.h" #include "../yvalve/MasterImplementation.h" -#include "../common/classes/ImplementHelper.h" #include "../common/classes/init.h" #include "../common/StatusHolder.h" #include "../yvalve/PluginManager.h" @@ -48,18 +47,6 @@ namespace Why { -class MasterImplementation : public StackIface<IMaster> -{ -public: - // IMaster implementation - IStatus* FB_CARG getStatus(); - IProvider* FB_CARG getDispatcher(); - IPluginManager* FB_CARG getPluginManager(); - int FB_CARG upgradeInterface(IInterface* toUpgrade, int desiredVersion, void* missingFunctionClass); - const char* FB_CARG circularAlloc(const char* s, size_t len, intptr_t thr); - ITimerControl* FB_CARG getTimerControl(); -}; - // // getStatus() // Modified: firebird/trunk/src/yvalve/MasterImplementation.h =================================================================== --- firebird/trunk/src/yvalve/MasterImplementation.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/yvalve/MasterImplementation.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -31,11 +31,28 @@ #include "firebird.h" #include "Interface.h" +#include "../common/classes/ImplementHelper.h" namespace Why { extern Firebird::IProvider* dispatcherPtr; + class MasterImplementation : public Firebird::StackIface<Firebird::IMaster> + { + public: + // IMaster implementation + Firebird::IStatus* FB_CARG getStatus(); + Firebird::IProvider* FB_CARG getDispatcher(); + Firebird::IPluginManager* FB_CARG getPluginManager(); + int FB_CARG upgradeInterface(Firebird::IInterface* toUpgrade, int desiredVersion, void* missingFunctionClass); + const char* FB_CARG circularAlloc(const char* s, size_t len, intptr_t thr); + Firebird::ITimerControl* FB_CARG getTimerControl(); + Firebird::IAttachment* registerAttachment(Firebird::IProvider* provider, + Firebird::IAttachment* attachment); + Firebird::ITransaction* registerTransaction(Firebird::IAttachment* attachment, + Firebird::ITransaction* transaction); + }; + void shutdownTimers(); } // namespace Why Modified: firebird/trunk/src/yvalve/PluginManager.cpp =================================================================== --- firebird/trunk/src/yvalve/PluginManager.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/yvalve/PluginManager.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -926,7 +926,7 @@ if (plugin->release() == 0) { - fb_assert(parent); + ///fb_assert(parent); if (parent) { parent->release(); Modified: firebird/trunk/src/yvalve/why.cpp =================================================================== --- firebird/trunk/src/yvalve/why.cpp 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/yvalve/why.cpp 2011-05-07 19:52:44 UTC (rev 52892) @@ -681,7 +681,7 @@ YEvents(YAttachment* aAttachment, IEvents* aNext, IEventCallback* aCallback); - virtual ~YEvents() + ~YEvents() { if (deleteCallback) delete callback; @@ -696,7 +696,7 @@ { if (next) { - next->release(); + next = NULL; destroy(); } @@ -732,7 +732,7 @@ { if (next) { - next->release(); + next = NULL; destroy(); } @@ -798,7 +798,7 @@ { if (next) { - next->release(); + next = NULL; destroy(); } @@ -850,7 +850,7 @@ { if (next) { - next->release(); + next = NULL; destroy(); } @@ -891,7 +891,7 @@ { if (next) { - next->release(); + next = NULL; destroy(); } @@ -968,12 +968,10 @@ handle = makeHandle(&attachments, this); } - virtual ~YAttachment() + ~YAttachment() { if (provider) - { PluginManagerInterfacePtr()->releasePlugin(provider); - } } void destroy(); @@ -986,7 +984,7 @@ { if (next) { - next->release(); + next = NULL; destroy(); } @@ -1000,7 +998,7 @@ virtual void FB_CARG getInfo(IStatus* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer); virtual YTransaction* FB_CARG startTransaction(IStatus* status, unsigned int tpbLength, - const unsigned char* tpb, FB_API_HANDLE api); + const unsigned char* tpb); virtual YTransaction* FB_CARG reconnectTransaction(IStatus* status, unsigned int length, const unsigned char* id); virtual YStatement* FB_CARG allocateStatement(IStatus* status); @@ -1059,12 +1057,10 @@ handle = makeHandle(&services, this); } - virtual ~YService() + ~YService() { if (provider) - { PluginManagerInterfacePtr()->releasePlugin(provider); - } } void destroy(); @@ -1076,7 +1072,7 @@ { if (next) { - next->release(); + next = NULL; destroy(); } @@ -1109,10 +1105,10 @@ } // IProvider implementation - virtual void FB_CARG attachDatabase(IStatus* status, IAttachment** attachment, - FB_API_HANDLE api, const char* filename, unsigned int dpbLength, const unsigned char* dpb); - virtual void FB_CARG createDatabase(IStatus* status, IAttachment** ptr, - FB_API_HANDLE api, const char* filename, unsigned int dpbLength, const unsigned char* dpb); + virtual YAttachment* FB_CARG attachDatabase(IStatus* status, const char* filename, + unsigned int dpbLength, const unsigned char* dpb); + virtual YAttachment* FB_CARG createDatabase(IStatus* status, const char* filename, + unsigned int dpbLength, const unsigned char* dpb); virtual YService* FB_CARG attachServiceManager(IStatus* status, const char* serviceName, unsigned int spbLength, const unsigned char* spb); virtual void FB_CARG shutdown(IStatus* status, unsigned int timeout, const int reason); @@ -1763,15 +1759,13 @@ PathName pathName(filename, fileLength ? fileLength : strlen(filename)); - IAttachment* attachment = NULL; - dispatcher->attachDatabase(&status, &attachment, 0, pathName.c_str(), dpbLength, + YAttachment* attachment = dispatcher->attachDatabase(&status, pathName.c_str(), dpbLength, reinterpret_cast<const UCHAR*>(dpb)); if (!status.isSuccess()) return status[1]; - YAttachment* yAttach = static_cast<YAttachment*>(attachment); - *publicHandle = yAttach->handle; + *publicHandle = attachment->handle; } catch (const Exception& e) { @@ -2044,15 +2038,13 @@ PathName pathName(filename, fileLength ? fileLength : strlen(filename)); - IAttachment* attachment = NULL; - dispatcher->createDatabase(&status, &attachment, 0, pathName.c_str(), dpbLength, + YAttachment* attachment = dispatcher->createDatabase(&status, pathName.c_str(), dpbLength, reinterpret_cast<const UCHAR*>(dpb)); if (!status.isSuccess()) return status[1]; - YAttachment* yAttach = static_cast<YAttachment*>(attachment); - *publicHandle = yAttach->handle; + *publicHandle = attachment->handle; } catch (const Exception& e) { @@ -3530,7 +3522,7 @@ RefPtr<YAttachment> attachment(translateHandle(attachments, vector->teb_database)); YTransaction* transaction = attachment->startTransaction(&status, - vector->teb_tpb_length, vector->teb_tpb, 0); + vector->teb_tpb_length, vector->teb_tpb); if (!status.isSuccess()) status_exception::raise(status); @@ -3747,9 +3739,62 @@ } +// Get the legacy handle of a database. +ISC_STATUS API_ROUTINE fb_get_database_handle(ISC_STATUS* userStatus, FB_API_HANDLE* handle, void* obj) +{ + StatusVector status(userStatus); + + try + { + YAttachment* yObject = static_cast<YAttachment*>(obj); + *handle = yObject->handle; + } + catch (const Exception& e) + { + e.stuffException(&status); + } + + return status[1]; +} + + +// Get the legacy handle of a transaction. +ISC_STATUS API_ROUTINE fb_get_transaction_handle(ISC_STATUS* userStatus, FB_API_HANDLE* handle, void* obj) +{ + StatusVector status(userStatus); + + try + { + YTransaction* yObject = static_cast<YTransaction*>(obj); + *handle = yObject->handle; + } + catch (const Exception& e) + { + e.stuffException(&status); + } + + return status[1]; +} + + //------------------------------------- +IAttachment* MasterImplementation::registerAttachment(IProvider* provider, IAttachment* attachment) +{ + return new YAttachment(provider, attachment, ""); +} + +ITransaction* MasterImplementation::registerTransaction(IAttachment* attachment, + ITransaction* transaction) +{ + return new YTransaction(static_cast<YAttachment*>(attachment), transaction); +} + + +//------------------------------------- + + YEvents::YEvents(YAttachment* aAttachment, IEvents* aNext, IEventCallback* aCallback) : attachment(aAttachment), next(aNext), @@ -3766,8 +3811,11 @@ removeHandle(&events, handle); - next = NULL; - release(); + if (next) + { + next = NULL; + release(); + } } void YEvents::cancel(IStatus* status) @@ -3812,8 +3860,11 @@ removeHandle(&requests, handle); - next = NULL; - release(); + if (next) + { + next = NULL; + release(); + } } void YRequest::receive(IStatus* status, int level, unsigned int msgType, @@ -3940,8 +3991,11 @@ removeHandle(&blobs, handle); - next = NULL; - release(); + if (next) + { + next = NULL; + release(); + } } void YBlob::getInfo(IStatus* status, unsigned int itemsLength, @@ -4061,8 +4115,11 @@ removeHandle(&statements, handle); - next = NULL; - release(); + if (next) + { + next = NULL; + release(); + } } void YStatement::prepare(IStatus* status, ITransaction* transaction, @@ -4334,8 +4391,11 @@ removeHandle(&transactions, handle); - next = NULL; - release(); + if (next) + { + next = NULL; + release(); + } } void YTransaction::getInfo(IStatus* status, unsigned int itemsLength, @@ -4674,8 +4734,11 @@ removeHandle(&attachments, handle); - next = NULL; - release(); + if (next) + { + next = NULL; + release(); + } } // Get the full database pathname and put it in the transaction description record. @@ -4715,13 +4778,13 @@ } YTransaction* YAttachment::startTransaction(IStatus* status, unsigned int tpbLength, - const unsigned char* tpb, FB_API_HANDLE api) + const unsigned char* tpb) { try { YEntry entry(status, this); - ITransaction* transaction = next->startTransaction(status, tpbLength, tpb, api); + ITransaction* transaction = next->startTransaction(status, tpbLength, tpb); if (transaction) transaction = new YTransaction(this, transaction); @@ -5064,8 +5127,11 @@ { removeHandle(&services, handle); - next = NULL; - release(); + if (next) + { + next = NULL; + release(); + } } void YService::detach(IStatus* status) @@ -5118,15 +5184,13 @@ // Attach a database through the first subsystem that recognizes it. -void Dispatcher::attachDatabase(IStatus* status, IAttachment** attachment, FB_API_HANDLE /*api*/, - const char* filename, unsigned int dpbLength, const unsigned char* dpb) +YAttachment* Dispatcher::attachDatabase(IStatus* status, const char* filename, + unsigned int dpbLength, const unsigned char* dpb) { try { YEntry entry(status); - *attachment = NULL; - if (shutdownStarted) status_exception::raise(Arg::Gds(isc_att_shutdown)); @@ -5213,18 +5277,15 @@ { IProvider* provider = providerIterator.plugin(); - provider->attachDatabase(currentStatus, attachment, 0, expandedFilename.c_str(), - newDpb.getBufferLength(), newDpb.getBuffer()); + IAttachment* attachment = provider->attachDatabase(currentStatus, + expandedFilename.c_str(), newDpb.getBufferLength(), newDpb.getBuffer()); if (currentStatus->isSuccess()) { - *attachment = new YAttachment(provider, *attachment, expandedFilename); status->set(currentStatus->get()); - return; + return new YAttachment(provider, attachment, expandedFilename); } - *attachment = NULL; - if (currentStatus->get()[1] != isc_unavailable) currentStatus = &temp; @@ -5236,22 +5297,19 @@ } catch (const Exception& e) { - if (*attachment) - (*attachment)->release(); - e.stuffException(status); } + + return NULL; } -void Dispatcher::createDatabase(IStatus* status, IAttachment** attachment, FB_API_HANDLE /*api*/, - const char* filename, unsigned int dpbLength, const unsigned char* dpb) +YAttachment* Dispatcher::createDatabase(IStatus* status, const char* filename, + unsigned int dpbLength, const unsigned char* dpb) { try { YEntry entry(status); - *attachment = NULL; - if (shutdownStarted) status_exception::raise(Arg::Gds(isc_att_shutdown)); @@ -5342,8 +5400,8 @@ { IProvider* provider = providerIterator.plugin(); - provider->createDatabase(currentStatus, attachment, 0, expandedFilename.c_str(), - newDpb.getBufferLength(), newDpb.getBuffer()); + IAttachment* attachment = provider->createDatabase(currentStatus, + expandedFilename.c_str(), newDpb.getBufferLength(), newDpb.getBuffer()); if (currentStatus->isSuccess()) { @@ -5354,13 +5412,10 @@ PathName path(orgFilename); #endif - *attachment = new YAttachment(provider, *attachment, path); status->set(currentStatus->get()); - return; + return new YAttachment(provider, attachment, path); } - *attachment = NULL; - if (currentStatus->get()[1] != isc_unavailable) currentStatus = &temp; @@ -5372,14 +5427,10 @@ } catch (const Exception& e) { - if (*attachment) - { - StatusVector temp(NULL); - (*attachment)->drop(&temp); - } - e.stuffException(status); } + + return NULL; } // Attach a service through the first subsystem that recognizes it. Modified: firebird/trunk/src/yvalve/why_proto.h =================================================================== --- firebird/trunk/src/yvalve/why_proto.h 2011-05-07 19:33:46 UTC (rev 52891) +++ firebird/trunk/src/yvalve/why_proto.h 2011-05-07 19:52:44 UTC (rev 52892) @@ -244,6 +244,9 @@ ISC_STATUS API_ROUTINE fb_ping(ISC_STATUS*, FB_API_HANDLE*); +ISC_STATUS API_ROUTINE fb_get_database_handle(ISC_STATUS*, FB_API_HANDLE*, void*); +ISC_STATUS API_ROUTINE fb_get_transaction_handle(ISC_STATUS*, FB_API_HANDLE*, void*); + typedef void AttachmentCleanupRoutine(FB_API_HANDLE*, void*); typedef void TransactionCleanupRoutine(FB_API_HANDLE, void*); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |