diff --git a/src/auth/AuthDbg.cpp b/src/auth/AuthDbg.cpp index 9ad6f27d75..7b22165293 100644 --- a/src/auth/AuthDbg.cpp +++ b/src/auth/AuthDbg.cpp @@ -41,14 +41,10 @@ extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) { const char* name = "Auth_Debug"; - Firebird::IPlugin* iPlugin = master->getPluginInterface(); + Firebird::PluginInterface iPlugin(master); - clientFactory->addRef(); iPlugin->registerPlugin(Firebird::PluginType::AuthClient, name, &clientFactory); - serverFactory->addRef(); iPlugin->registerPlugin(Firebird::PluginType::AuthServer, name, &serverFactory); - - iPlugin->release(); } diff --git a/src/auth/AuthInterface.h b/src/auth/AuthInterface.h index 763d37d864..68dcfa8282 100644 --- a/src/auth/AuthInterface.h +++ b/src/auth/AuthInterface.h @@ -39,22 +39,20 @@ namespace Auth { enum Result {AUTH_SUCCESS, AUTH_CONTINUE, AUTH_FAILED, AUTH_MORE_DATA}; -class WriterInterface : public Firebird::Interface +class WriterInterface : public Firebird::IDisposable { public: virtual void FB_CARG reset() = 0; virtual void FB_CARG add(const char* user, const char* method, const char* details) = 0; }; -#define FB_AUTH_WRITER_VERSION (FB_INTERFACE_VERSION + 2) -class DpbInterface : public Firebird::Interface +class DpbInterface : public Firebird::IDisposable { public: virtual int FB_CARG find(UCHAR tag) = 0; virtual void FB_CARG add(UCHAR tag, const void* bytes, unsigned int count) = 0; virtual void FB_CARG drop() = 0; }; -#define FB_AUTH_DBP_VERSION (FB_INTERFACE_VERSION + 3) class Server : public Firebird::Plugin { @@ -77,14 +75,13 @@ public: }; #define FB_AUTH_CLIENT_VERSION (FB_PLUGIN_VERSION + 3) -class UserField : public Firebird::Interface +class UserField : public Firebird::IDisposable { public: virtual int FB_CARG entered() = 0; virtual int FB_CARG specified() = 0; virtual void FB_CARG setEntered(int newValue) = 0; }; -#define FB_USER_FIELD_VERSION (FB_INTERFACE_VERSION + 3) class CharUserField : public UserField { @@ -92,7 +89,6 @@ public: virtual const char* FB_CARG get() = 0; virtual void FB_CARG set(const char* newValue) = 0; }; -#define FB_AUTH_CHAR_USER_VERSION (FB_USER_FIELD_VERSION + 2) class IntUserField : public UserField { @@ -100,9 +96,8 @@ public: virtual int FB_CARG get() = 0; virtual void FB_CARG set(int newValue) = 0; }; -#define FB_AUTH_INT_USER_VERSION (FB_USER_FIELD_VERSION + 2) -class User : public Firebird::Interface +class User : public Firebird::IDisposable { public: virtual int FB_CARG operation() = 0; @@ -121,16 +116,14 @@ public: virtual void FB_CARG clear() = 0; }; -#define FB_AUTH_USER_VERSION (FB_INTERFACE_VERSION + 11) -class ListUsers : public Firebird::Interface +class ListUsers : public Firebird::IDisposable { public: virtual void FB_CARG list(User* user) = 0; }; -#define FB_AUTH_LIST_USERS_VERSION (FB_INTERFACE_VERSION + 1) -class LogonInfo : public Firebird::Interface +class LogonInfo : public Firebird::IDisposable { public: virtual const char* FB_CARG name() = 0; @@ -139,7 +132,6 @@ public: virtual const char* FB_CARG networkProtocol() = 0; virtual const char* FB_CARG remoteAddress() = 0; }; -#define FB_AUTH_LOGON_INFO_VERSION (FB_INTERFACE_VERSION + 5) class Management : public Firebird::Plugin { diff --git a/src/auth/SecurityDatabase/LegacyClient.cpp b/src/auth/SecurityDatabase/LegacyClient.cpp index 860432fd22..cacfabd960 100644 --- a/src/auth/SecurityDatabase/LegacyClient.cpp +++ b/src/auth/SecurityDatabase/LegacyClient.cpp @@ -66,7 +66,6 @@ namespace { void registerLegacyClient(Firebird::IPlugin* iPlugin) { - factory->addRef(); iPlugin->registerPlugin(Firebird::PluginType::AuthClient, "Legacy_Auth", &factory); } diff --git a/src/auth/SecurityDatabase/LegacyManagement.epp b/src/auth/SecurityDatabase/LegacyManagement.epp index 3469d566a8..6fefb54472 100644 --- a/src/auth/SecurityDatabase/LegacyManagement.epp +++ b/src/auth/SecurityDatabase/LegacyManagement.epp @@ -672,11 +672,8 @@ static Firebird::UnloadDetector unloadDetector; extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) { - Firebird::IPlugin* iPlugin = master->getPluginInterface(); + Firebird::PluginInterface pi(master); - factory->addRef(); - iPlugin->registerPlugin(Firebird::PluginType::AuthUserManagement, "Legacy_Auth", &factory); - iPlugin->setModuleCleanup(&unloadDetector); - - iPlugin->release(); + pi->registerPlugin(Firebird::PluginType::AuthUserManagement, "Legacy_Auth", &factory); + pi->setModuleCleanup(&unloadDetector); } diff --git a/src/auth/SecurityDatabase/LegacyServer.cpp b/src/auth/SecurityDatabase/LegacyServer.cpp index 724bb2c7a1..038b9e6a5f 100644 --- a/src/auth/SecurityDatabase/LegacyServer.cpp +++ b/src/auth/SecurityDatabase/LegacyServer.cpp @@ -508,6 +508,7 @@ Result SecurityDatabaseServer::startAuthentication(Firebird::Status* status, if (!instance) { instance = new SecurityDatabase; + instance->addRef(); secDbName.copyTo(instance->secureDbName, sizeof(instance->secureDbName)); curInstances.add(instance); } @@ -557,7 +558,6 @@ namespace { void registerLegacyServer(Firebird::IPlugin* iPlugin) { - factory->addRef(); iPlugin->registerPlugin(Firebird::PluginType::AuthServer, "Legacy_Auth", &factory); } diff --git a/src/auth/SecurityDatabase/LegacyServer.h b/src/auth/SecurityDatabase/LegacyServer.h index ff1be2fad2..7d340c9baa 100644 --- a/src/auth/SecurityDatabase/LegacyServer.h +++ b/src/auth/SecurityDatabase/LegacyServer.h @@ -43,12 +43,6 @@ namespace Auth { -class SecurityDatabaseServerFactory : public Firebird::StdIface -{ -public: - Firebird::Plugin* FB_CARG createPlugin(const char* name, const char* configFile); -}; - class SecurityDatabaseServer : public Firebird::StdPlugin { public: diff --git a/src/common/Auth.h b/src/common/Auth.h index 1e2dc87407..569af2e049 100644 --- a/src/common/Auth.h +++ b/src/common/Auth.h @@ -41,7 +41,7 @@ namespace Auth { bool legacy(const char* nm); -class WriterImplementation : public Firebird::StackIface +class WriterImplementation : public Firebird::StackIface { public: WriterImplementation(bool svcFlag); @@ -57,7 +57,7 @@ private: unsigned char tag; }; -class DpbImplementation : public Firebird::StackIface +class DpbImplementation : public Firebird::StackIface { public: DpbImplementation(Firebird::ClumpletWriter& base); diff --git a/src/common/StatusHolder.h b/src/common/StatusHolder.h index 40b9ea1950..6f7ccf2461 100644 --- a/src/common/StatusHolder.h +++ b/src/common/StatusHolder.h @@ -73,7 +73,7 @@ private: ISC_STATUS vector[40]; // FixMe - may be a kind of dynamic storage will be better? }; -class LocalStatus : public StackIface +class LocalStatus : public StackIface { }; diff --git a/src/common/call_service.cpp b/src/common/call_service.cpp index cc8a8a824c..c4bed1f44f 100644 --- a/src/common/call_service.cpp +++ b/src/common/call_service.cpp @@ -425,7 +425,7 @@ void callRemoteServiceManager(ISC_STATUS* status, { const char request[] = {isc_info_svc_get_users}; int startQuery = 0; - Auth::UserData uData; + Auth::StackUserData uData; for (;;) { diff --git a/src/common/classes/GetPlugins.h b/src/common/classes/GetPlugins.h index e6f4cafb02..fb19d13da8 100644 --- a/src/common/classes/GetPlugins.h +++ b/src/common/classes/GetPlugins.h @@ -55,6 +55,7 @@ public: desiredVersion, &missing, NULL)), currentPlugin(NULL) { + pluginSet->release(); getPlugin(); } @@ -65,6 +66,7 @@ public: desiredVersion, &missing, new FirebirdConf(knownConfig))), currentPlugin(NULL) { + pluginSet->release(); getPlugin(); } @@ -117,16 +119,13 @@ public: pluginInterface->releasePlugin(currentPlugin); currentPlugin = NULL; } - if (pluginSet) - pluginSet->release(); } private: AutoPtr masterInterface; AutoPtr pluginInterface; M missing; -// AutoPtr pluginSet; - IPluginSet *pluginSet; + RefPtr pluginSet; P* currentPlugin; void getPlugin() diff --git a/src/common/classes/ImplementHelper.h b/src/common/classes/ImplementHelper.h index 3b6699c776..efd76b8a88 100644 --- a/src/common/classes/ImplementHelper.h +++ b/src/common/classes/ImplementHelper.h @@ -35,6 +35,8 @@ #include "gen/iberror.h" #include "../yvalve/gds_proto.h" #include "../common/classes/init.h" +#include "../common/classes/auto.h" +#include "../common/classes/RefCounted.h" #include "consts_pub.h" extern "C" int API_ROUTINE fb_shutdown(unsigned int timeout, const int reason); @@ -46,61 +48,34 @@ namespace Firebird { class AutoInterface { public: - static void clear(Interface* ptr) + static void clear(IDisposable* ptr) { if (ptr) { - ptr->release(); + ptr->dispose(); } } }; // Implement standard interface and plugin functions -template -class Versioned : public C, public S +template +class DisposeIface : public C, public S { public: - int FB_CARG version() - { - return V; - } + DisposeIface() { } + +private: + DisposeIface(const DisposeIface&); + DisposeIface& operator=(const DisposeIface&); }; -template -class StackIface : public Versioned +template +class StackIface : public DisposeIface { -#ifdef DEV_BUILD -private: - int counter; - public: - // StackIface is destroyed in same frame where created, - // therefore final release() call is not expected, - // therefore initialize check counter with 0, not 1. - StackIface() : counter(0) { } - - ~StackIface() - { - fb_assert(counter == 0); - } -#endif - -public: - void FB_CARG addRef() - { -#ifdef DEV_BUILD - ++counter; -#endif - } - - int FB_CARG release() - { -#ifdef DEV_BUILD - --counter; -#endif - return 1; - } + void FB_CARG dispose() + { } void* operator new(size_t, void* memory) throw() { @@ -109,15 +84,20 @@ public: }; template -class StdIface : public Versioned +class StdIface : public C, public S { public: - StdIface() : refCounter(1) { } + StdIface() : refCounter(0) { } + + int FB_CARG version() + { + return V; + } #ifdef DEV_BUILD ~StdIface() { -// fb_assert(refCounter.value() == 0); + fb_assert(refCounter.value() == 0); } #endif @@ -156,12 +136,14 @@ public: // Trivial factory template -class SimpleFactoryBase : public StackIface +class SimpleFactoryBase : public StackIface { public: Plugin* FB_CARG createPlugin(IFactoryParameter* factoryParameter) { - return new P(factoryParameter); + P* p = new P(factoryParameter); + p->addRef(); + return p; } }; @@ -184,12 +166,10 @@ public: class PluginInterface : public AutoPtr { public: - PluginInterface() : AutoPtr(NULL) - { - IMaster* mi = fb_get_master_interface(); - reset(mi->getPluginInterface()); - mi->release(); - } + PluginInterface() : AutoPtr(fb_get_master_interface()->getPluginInterface()) + { } + PluginInterface(IMaster* master) : AutoPtr(master->getPluginInterface()) + { } }; @@ -197,12 +177,8 @@ public: class TimerInterface : public AutoPtr { public: - TimerInterface() : AutoPtr(NULL) - { - IMaster* mi = fb_get_master_interface(); - reset(mi->getTimerControl()); - mi->release(); - } + TimerInterface() : AutoPtr(fb_get_master_interface()->getTimerControl()) + { } }; @@ -216,7 +192,7 @@ class DummyStorage { }; -class UnloadDetectorHelper : public StdIface +class UnloadDetectorHelper : public DisposeIface { public: UnloadDetectorHelper(MemoryPool&) @@ -234,17 +210,6 @@ public: } } - int FB_CARG release() - { - if (--refCounter == 0) - { - //delete this; - fb_assert(false); - return 0; - } - return 1; - } - bool unloadStarted() { return !flagOsUnload; @@ -255,6 +220,11 @@ public: cleanup = c; } + void FB_CARG dispose() + { + // delete this; -don't do that! + } + private: bool flagOsUnload; FPTR_VOID cleanup; diff --git a/src/common/fb_exception.cpp b/src/common/fb_exception.cpp index 303fb96183..4f8b0f3c3d 100644 --- a/src/common/fb_exception.cpp +++ b/src/common/fb_exception.cpp @@ -36,9 +36,7 @@ void makePermanentVector(ISC_STATUS* perm, const ISC_STATUS* trans, FB_THREAD_ID perm [-1] = isc_arg_string; const size_t len = *trans++; const char* temp = reinterpret_cast(*trans++); - IMaster* im = fb_get_master_interface(); - *perm++ = (ISC_STATUS)(IPTR) (im->circularAlloc(temp, len, thr)); - im->release(); + *perm++ = (ISC_STATUS)(IPTR) (MasterInterface()->circularAlloc(temp, len, thr)); } break; case isc_arg_string: @@ -47,9 +45,7 @@ void makePermanentVector(ISC_STATUS* perm, const ISC_STATUS* trans, FB_THREAD_ID { const char* temp = reinterpret_cast(*trans++); const size_t len = strlen(temp); - IMaster* im = fb_get_master_interface(); - *perm++ = (ISC_STATUS)(IPTR) (im->circularAlloc(temp, len, thr)); - im->release(); + *perm++ = (ISC_STATUS)(IPTR) (MasterInterface()->circularAlloc(temp, len, thr)); } break; default: diff --git a/src/common/security.h b/src/common/security.h index c23421e185..2040738020 100644 --- a/src/common/security.h +++ b/src/common/security.h @@ -30,7 +30,7 @@ namespace Auth { -class CharField : public Firebird::StackIface +class CharField : public Firebird::StackIface { public: CharField() @@ -87,7 +87,7 @@ private: Firebird::string value; }; -class IntField : public Firebird::StackIface +class IntField : public Firebird::StackIface { public: IntField() @@ -139,7 +139,7 @@ private: int value; }; -class UserData : public Firebird::StackIface +class UserData : public User { public: UserData() @@ -204,6 +204,10 @@ public: CharField database, dba, dbaPassword, role, trustedUser; }; +class StackUserData : public Firebird::StackIface +{ +}; + class Get : public Firebird::GetPlugins { public: diff --git a/src/dsql/dsql.cpp b/src/dsql/dsql.cpp index 7ff706c79b..aef25cedbf 100644 --- a/src/dsql/dsql.cpp +++ b/src/dsql/dsql.cpp @@ -161,6 +161,7 @@ dsql_req* DSQL_allocate_statement(thread_db* tdbb, Jrd::Attachment* attachment) MemoryPool& pool = *tdbb->getDefaultPool(); DsqlCompiledStatement* statement = FB_NEW(pool) DsqlCompiledStatement(pool); dsql_req* const request = FB_NEW(pool) dsql_req(statement); + request->addRef(); request->req_dbb = database; return request; @@ -1873,6 +1874,7 @@ static dsql_req* prepareStatement(thread_db* tdbb, dsql_dbb* database, jrd_tra* scratch->clientDialect = client_dialect; dsql_req* request = FB_NEW(statement->getPool()) dsql_req(statement); + request->addRef(); request->req_dbb = database; request->req_transaction = transaction; diff --git a/src/gpre/boot/gpre_meta_boot.cpp b/src/gpre/boot/gpre_meta_boot.cpp index 3169650093..c3c577c0d2 100644 --- a/src/gpre/boot/gpre_meta_boot.cpp +++ b/src/gpre/boot/gpre_meta_boot.cpp @@ -677,20 +677,10 @@ using namespace Firebird; class DummyMasterImpl : public IMaster { public: - virtual void FB_CARG addRef() + virtual void FB_CARG dispose() { } - virtual int FB_CARG release() - { - return 1; - } - - virtual int FB_CARG version() - { - return IMaster::VERSION; - } - virtual Status* FB_CARG getStatusInstance() { fb_assert(false); diff --git a/src/include/FirebirdPluginApi.h b/src/include/FirebirdPluginApi.h index c23f03352a..04ff896f3a 100644 --- a/src/include/FirebirdPluginApi.h +++ b/src/include/FirebirdPluginApi.h @@ -142,25 +142,23 @@ public: #define FB_FACTORY_PARAMETER_VERSION (FB_INTERFACE_VERSION + 3) // Required to creat instances of given plugin -class PluginsFactory : public Interface +class PluginsFactory : public IDisposable { public: virtual Plugin* FB_CARG createPlugin(IFactoryParameter* factoryParameter) = 0; }; -#define FB_PLUGINS_FACTORY_VERSION (FB_INTERFACE_VERSION + 1) // Required to let plugins manager invoke module's cleanup routine before unloading it. // For some OS/compiler this may be done in dtor of global variable in module itself. // Others (Windows/VC) fail to create some very useful resources (threads) when module is unloading. -class IModuleCleanup : public Interface +class IModuleCleanup : public IDisposable { public: virtual void FB_CARG doClean() = 0; }; -#define FB_MODULE_CLEANUP_VERSION (FB_INTERFACE_VERSION + 1) // Interface to deal with plugins here and there, returned by master interface -class IPlugin : public Interface +class IPlugin : public IDisposable { public: // Main function called by plugin modules in firebird_plugin() @@ -188,7 +186,6 @@ public: // will cause resources leak virtual void FB_CARG releasePlugin(Plugin* plugin) = 0; }; -#define FB_I_PLUGIN_VERSION (FB_INTERFACE_VERSION + 5) typedef void StartLoadedModule(IMaster* masterInterface); diff --git a/src/include/Interface.h b/src/include/Interface.h index 1aca779a74..1364305422 100644 --- a/src/include/Interface.h +++ b/src/include/Interface.h @@ -43,7 +43,7 @@ namespace Firebird { -// Regular interface - base for all FB interfaces +// Regular interface - base for refCounted FB interfaces class Interface { public: @@ -53,8 +53,15 @@ public: }; #define FB_INTERFACE_VERSION 3 // If this is changed, types of all interfaces must be changed +// Disposable interface - base for static and onStack interfaces, may be used in regular case too +class IDisposable +{ +public: + virtual void FB_CARG dispose() = 0; +}; + // Interface to work with status vector -class Status : public Interface +class Status : public IDisposable { public: virtual void FB_CARG set(unsigned int length, const ISC_STATUS* value) = 0; @@ -64,12 +71,11 @@ public: virtual const ISC_STATUS* FB_CARG get() const = 0; virtual int FB_CARG isSuccess() const = 0; }; -#define FB_STATUS_VERSION (FB_INTERFACE_VERSION + 5) class IPlugin; class ITimerControl; -class IMaster : public Interface +class IMaster : public IDisposable { public: // This interface can't be upgraded - therefore another form of version is used diff --git a/src/include/Timer.h b/src/include/Timer.h index 1a2c3f217c..e14b1c30db 100644 --- a/src/include/Timer.h +++ b/src/include/Timer.h @@ -45,7 +45,7 @@ public: typedef ISC_INT64 TimerDelay; // Interface to set timer for particular time -class ITimerControl : public Interface +class ITimerControl : public IDisposable { public: // Set timer @@ -53,7 +53,6 @@ public: // Stop timer virtual void FB_CARG stop(ITimer* timer) = 0; }; -#define FB_I_TIMER_CONTROL_VERSION (FB_INTERFACE_VERSION + 2) } // namespace Firebird diff --git a/src/include/fb_blk.h b/src/include/fb_blk.h index 75675429b8..bf44d55904 100644 --- a/src/include/fb_blk.h +++ b/src/include/fb_blk.h @@ -51,6 +51,7 @@ enum BlockType type_prf, type_ctl, type_Events, + type_user_data, type_PageSpace, type_PageManager, diff --git a/src/jrd/Attachment.cpp b/src/jrd/Attachment.cpp index d9663f99cc..7a69a968b8 100644 --- a/src/jrd/Attachment.cpp +++ b/src/jrd/Attachment.cpp @@ -56,6 +56,7 @@ Jrd::Attachment* Jrd::Attachment::create(Database* dbb, FB_API_HANDLE publicHand { Attachment* const attachment = FB_NEW(*pool) Attachment(pool, dbb, publicHandle); pool->setStatsGroup(attachment->att_memory_stats); + attachment->addRef(); return attachment; } catch (const Firebird::Exception&) diff --git a/src/jrd/JrdStatement.cpp b/src/jrd/JrdStatement.cpp index 5f6ee1777e..be5be3cf69 100644 --- a/src/jrd/JrdStatement.cpp +++ b/src/jrd/JrdStatement.cpp @@ -230,6 +230,7 @@ JrdStatement* JrdStatement::makeStatement(thread_db* tdbb, CompilerScratch* csb, MemoryPool* const pool = tdbb->getDefaultPool(); statement = FB_NEW(*pool) JrdStatement(tdbb, pool, csb); + statement->addRef(); tdbb->setRequest(old_request); } // try diff --git a/src/jrd/UserManagement.cpp b/src/jrd/UserManagement.cpp index d2c5118731..0559f41cab 100644 --- a/src/jrd/UserManagement.cpp +++ b/src/jrd/UserManagement.cpp @@ -71,7 +71,7 @@ UserManagement::UserManagement(jrd_tra* tra) fb_assert(manager); manager->addRef(); - class UserIdInfo : public StackIface + class UserIdInfo : public StackIface { public: UserIdInfo(const Attachment* pAtt) @@ -297,7 +297,7 @@ RecordBuffer* UserManagement::getList(thread_db* tdbb, jrd_rel* relation) fb_assert(buffer); LocalStatus status; - Auth::UserData u; + Auth::StackUserData u; u.op = DIS_OPER; int errcode = manager->execute(&status, &u, &display); checkSecurityResult(errcode, &status, "Unknown"); diff --git a/src/jrd/UserManagement.h b/src/jrd/UserManagement.h index 53e14ef117..306ca47e4f 100644 --- a/src/jrd/UserManagement.h +++ b/src/jrd/UserManagement.h @@ -54,7 +54,7 @@ protected: class UserManagement : public DataDump { public: - class Display : public Firebird::StackIface + class Display : public Firebird::StackIface { public: Display(UserManagement* um) diff --git a/src/jrd/blb.cpp b/src/jrd/blb.cpp index f7063296bd..53a22dfaa2 100644 --- a/src/jrd/blb.cpp +++ b/src/jrd/blb.cpp @@ -1894,6 +1894,7 @@ static blb* allocate_blob(thread_db* tdbb, jrd_tra* transaction) // Create a blob large enough to hold a single data page. blb* blob = FB_NEW(*transaction->tra_pool) blb(*transaction->tra_pool, dbb->dbb_page_size); + blob->addRef(); blob->blb_attachment = tdbb->getAttachment(); blob->blb_transaction = transaction; diff --git a/src/jrd/dyn.epp b/src/jrd/dyn.epp index ac4260f2d1..f58a6801d2 100644 --- a/src/jrd/dyn.epp +++ b/src/jrd/dyn.epp @@ -1970,7 +1970,16 @@ static void dyn_user(Global* gbl, const UCHAR** ptr) ISC_STATUS_ARRAY status; try { - Auth::UserData* userData = new((void*)(FB_NEW(*tra->tra_pool) char[sizeof(Auth::UserData)])) Auth::UserData; + class DisposeableUserData : public Firebird::DisposeIface > + { + public: + void FB_CARG dispose() + { + delete this; + } + }; + + DisposeableUserData* userData = FB_NEW(*tra->tra_pool) DisposeableUserData; UCHAR verb; while ((verb = *(*ptr)++) != isc_user_end) { diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index 1199758e8c..6118165bb8 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -281,7 +281,7 @@ int Provider::release() static Firebird::UnloadDetector unloadDetector; -class EngineFactory : public StackIface +class EngineFactory : public StackIface { public: Plugin* FB_CARG createPlugin(IFactoryParameter* factoryParameter) @@ -292,7 +292,9 @@ public: } ++shutdownCounter; - return new Provider(factoryParameter); + Plugin* p = new Provider(factoryParameter); + p->addRef(); + return p; } }; @@ -300,7 +302,6 @@ static Static engineFactory; void registerEngine(IPlugin* iPlugin) { - engineFactory->addRef(); iPlugin->registerPlugin(PluginType::Provider, "Engine12", &engineFactory); iPlugin->setModuleCleanup(&unloadDetector); } @@ -309,9 +310,8 @@ void registerEngine(IPlugin* iPlugin) extern "C" void FB_PLUGIN_ENTRY_POINT(IMaster* master) { - IPlugin* pi = master->getPluginInterface(); + PluginInterface pi; registerEngine(pi); - pi->release(); } namespace @@ -691,7 +691,7 @@ private: /// trace manager support -class TraceFailedConnection : public StackIface +class TraceFailedConnection : public StackIface { public: TraceFailedConnection(const char* filename, const DatabaseOptions* options); @@ -976,7 +976,9 @@ const char SINGLE_QUOTE = '\''; PProvider* currentProvider() { - return new Provider(NULL); + PProvider* p = new Provider(NULL); + p->addRef(); + return p; } // External hook definitions @@ -3029,6 +3031,7 @@ Firebird::IEvents* Attachment::queEvents(Status* user_status, Firebird::EventCal lock->lck_length, (const TEXT*) &lock->lck_key, length, events, callback); ev = FB_NEW(*getDefaultMemoryPool()) Events(id, this); + ev->addRef(); } catch (const Exception& ex) { @@ -3407,6 +3410,7 @@ Firebird::IService* Provider::attachServiceManager(Status* user_status, const ch ThreadContextHolder tdbb(user_status); svc = new Svc(new Service(service_name, spbLength, spb)); + svc->addRef(); } catch (const Exception& ex) { diff --git a/src/jrd/ntrace.h b/src/jrd/ntrace.h index 7e6954b079..67c1fd05f4 100644 --- a/src/jrd/ntrace.h +++ b/src/jrd/ntrace.h @@ -37,7 +37,7 @@ struct PerformanceInfo; -class TraceConnection : public Firebird::Interface +class TraceConnection : public Firebird::IDisposable { public: virtual int FB_CARG getConnectionID() = 0; @@ -52,7 +52,6 @@ public: virtual int FB_CARG getRemoteProcessID() = 0; virtual const char* FB_CARG getRemoteProcessName() = 0; }; -#define FB_TRACE_CONNECTION_VERSION (FB_INTERFACE_VERSION + 10) enum ntrace_tra_isolation_t { @@ -62,7 +61,7 @@ enum ntrace_tra_isolation_t tra_iso_read_committed_norecver }; -class TraceTransaction : public Firebird::Interface +class TraceTransaction : public Firebird::IDisposable { public: virtual int FB_CARG getTransactionID() = 0; @@ -71,25 +70,22 @@ public: virtual ntrace_tra_isolation_t FB_CARG getIsolation() = 0; virtual PerformanceInfo* FB_CARG getPerf() = 0; }; -#define FB_TRACE_TRANSACTION_VERSION (FB_INTERFACE_VERSION + 5) typedef int ntrace_relation_t; -class TraceParams : public Firebird::Interface +class TraceParams : public Firebird::IDisposable { public: virtual size_t FB_CARG getCount() = 0; virtual const struct dsc* FB_CARG getParam(size_t idx) = 0; }; -#define FB_TRACE_PARAMS_VERSION (FB_INTERFACE_VERSION + 2) -class TraceStatement : public Firebird::Interface +class TraceStatement : public Firebird::IDisposable { public: virtual int FB_CARG getStmtID() = 0; virtual PerformanceInfo* FB_CARG getPerf() = 0; }; -#define FB_TRACE_STATEMENT_VERSION (FB_INTERFACE_VERSION + 2) class TraceSQLStatement : public TraceStatement { @@ -99,7 +95,6 @@ public: virtual TraceParams* FB_CARG getInputs() = 0; virtual const char* FB_CARG getTextUTF8() = 0; }; -#define FB_TRACE_SQL_VERSION (FB_TRACE_STATEMENT_VERSION + 4) class TraceBLRStatement : public TraceStatement { @@ -108,36 +103,32 @@ public: virtual size_t FB_CARG getDataLength() = 0; virtual const char* FB_CARG getText() = 0; }; -#define FB_TRACE_BLR_VERSION (FB_TRACE_STATEMENT_VERSION + 3) -class TraceDYNRequest : public Firebird::Interface +class TraceDYNRequest : public Firebird::IDisposable { public: virtual const unsigned char* FB_CARG getData() = 0; virtual size_t FB_CARG getDataLength() = 0; virtual const char* FB_CARG getText() = 0; }; -#define FB_TRACE_DYN_VERSION (FB_INTERFACE_VERSION + 3) -class TraceContextVariable : public Firebird::Interface +class TraceContextVariable : public Firebird::IDisposable { public: virtual const char* FB_CARG getNameSpace() = 0; virtual const char* FB_CARG getVarName() = 0; virtual const char* FB_CARG getVarValue() = 0; }; -#define FB_TRACE_CONTEXT_VARIABLE_VERSION (FB_INTERFACE_VERSION + 3) -class TraceProcedure : public Firebird::Interface +class TraceProcedure : public Firebird::IDisposable { public: virtual const char* FB_CARG getProcName() = 0; virtual TraceParams* FB_CARG getInputs() = 0; virtual PerformanceInfo* FB_CARG getPerf() = 0; }; -#define FB_TRACE_PROCEDURE_VERSION (FB_INTERFACE_VERSION + 3) -class TraceTrigger : public Firebird::Interface +class TraceTrigger : public Firebird::IDisposable { public: virtual const char* FB_CARG getTriggerName() = 0; @@ -146,11 +137,10 @@ public: virtual int FB_CARG getWhich() = 0; virtual PerformanceInfo* FB_CARG getPerf() = 0; }; -#define FB_TRACE_TRIGGER_VERSION (FB_INTERFACE_VERSION + 5) typedef void* ntrace_service_t; -class TraceService : public Firebird::Interface +class TraceService : public Firebird::IDisposable { public: virtual ntrace_service_t FB_CARG getServiceID() = 0; @@ -165,7 +155,6 @@ public: virtual int FB_CARG getRemoteProcessID() = 0; virtual const char* FB_CARG getRemoteProcessName() = 0; }; -#define FB_TRACE_SERVICE_VERSION (FB_INTERFACE_VERSION + 10) // Plugin-specific argument. Passed by the engine to each hook @@ -239,7 +228,7 @@ public: }; #define FB_TRACE_LOG_WRITER_VERSION (FB_INTERFACE_VERSION + 1) -class TraceInitInfo : public Firebird::Interface +class TraceInitInfo : public Firebird::IDisposable { public: virtual const char* FB_CARG getConfigText() = 0; @@ -250,7 +239,6 @@ public: virtual TraceConnection* FB_CARG getConnection() = 0; virtual TraceLogWriter* FB_CARG getLogWriter() = 0; }; -#define FB_TRACE_INIT_INFO_VERSION (FB_INTERFACE_VERSION + 7) // API of trace plugin. Used to deliver notifications for each database diff --git a/src/jrd/tra.cpp b/src/jrd/tra.cpp index 4dcb19a514..d8237fc6cb 100644 --- a/src/jrd/tra.cpp +++ b/src/jrd/tra.cpp @@ -759,6 +759,7 @@ void TRA_init(Jrd::Attachment* attachment) MemoryPool* const pool = dbb->dbb_permanent; jrd_tra* const trans = FB_NEW(*pool) jrd_tra(pool, &dbb->dbb_memory_stats, NULL, NULL); + trans->addRef(); trans->tra_attachment = attachment; attachment->setSysTransaction(trans); trans->tra_flags |= TRA_system | TRA_ignore_limbo; diff --git a/src/jrd/tra.h b/src/jrd/tra.h index c6d99befdc..3d3db7ea73 100644 --- a/src/jrd/tra.h +++ b/src/jrd/tra.h @@ -187,6 +187,7 @@ public: pool->setStatsGroup(transaction->tra_memory_stats); } + transaction->addRef(); return transaction; } diff --git a/src/jrd/trace/TraceConfigStorage.cpp b/src/jrd/trace/TraceConfigStorage.cpp index 9ca6a85988..bbde33d2d5 100644 --- a/src/jrd/trace/TraceConfigStorage.cpp +++ b/src/jrd/trace/TraceConfigStorage.cpp @@ -80,6 +80,7 @@ void checkFileError(const char* filename, const char* operation, ISC_STATUS iscE } ConfigStorage::ConfigStorage() + : timer(new TouchFile) { m_cfg_file = -1; m_dirty = false; @@ -121,14 +122,14 @@ ConfigStorage::ConfigStorage() StorageGuard guard(this); checkFile(); - timer.start(sh_mem_header->cfg_file_name); + timer->start(sh_mem_header->cfg_file_name); ++sh_mem_header->cnt_uses; } ConfigStorage::~ConfigStorage() { - timer.stop(); + timer->stop(); ::close(m_cfg_file); m_cfg_file = -1; @@ -567,4 +568,15 @@ void ConfigStorage::TouchFile::stop() TimerInterface()->stop(this); } +int FB_CARG ConfigStorage::TouchFile::release() +{ + if (--refCounter == 0) + { + delete this; + return 0; + } + + return 1; +} + } // namespace Jrd diff --git a/src/jrd/trace/TraceConfigStorage.h b/src/jrd/trace/TraceConfigStorage.h index cf06f86d0e..10f3bb27d0 100644 --- a/src/jrd/trace/TraceConfigStorage.h +++ b/src/jrd/trace/TraceConfigStorage.h @@ -33,6 +33,7 @@ #include "../../common/classes/init.h" #include "../../common/isc_s_proto.h" #include "../../jrd/trace/TraceSession.h" +#include "../../common/classes/RefCounted.h" namespace Jrd { @@ -69,16 +70,17 @@ private: void checkFile(); void touchFile(); - class TouchFile : public Firebird::StackIface + class TouchFile : public Firebird::StdIface { public: void FB_CARG handler(); void start(const char* fName); void stop(); + int FB_CARG release(); private: const char* fileName; }; - TouchFile timer; + Firebird::RefPtr timer; void checkDirty() { diff --git a/src/jrd/trace/TraceObjects.cpp b/src/jrd/trace/TraceObjects.cpp index 6ab4262103..1145397bf6 100644 --- a/src/jrd/trace/TraceObjects.cpp +++ b/src/jrd/trace/TraceObjects.cpp @@ -427,7 +427,7 @@ const char* TraceTriggerImpl::getRelationName() /// TraceLogWriterImpl -class TraceLogWriterImpl : public StdIface +class TraceLogWriterImpl : public StdIface { public: TraceLogWriterImpl(const TraceSession& session) : @@ -502,6 +502,7 @@ TraceLogWriter* TraceInitInfoImpl::getLogWriter() { m_logWriter = new TraceLogWriterImpl(m_session); } + m_logWriter->addRef(); return m_logWriter; } diff --git a/src/jrd/trace/TraceObjects.h b/src/jrd/trace/TraceObjects.h index 75c3c92ed4..6ddb86a29d 100644 --- a/src/jrd/trace/TraceObjects.h +++ b/src/jrd/trace/TraceObjects.h @@ -49,7 +49,7 @@ class Database; class Attachment; class jrd_tra; -class TraceConnectionImpl : public Firebird::StackIface +class TraceConnectionImpl : public Firebird::StackIface { public: TraceConnectionImpl(const Attachment* att) : @@ -72,7 +72,7 @@ private: }; -class TraceTransactionImpl : public Firebird::StackIface +class TraceTransactionImpl : public Firebird::StackIface { public: TraceTransactionImpl(const jrd_tra* tran, PerformanceInfo* perf = NULL) : @@ -92,7 +92,7 @@ private: }; -class BLRPrinter : public Firebird::StackIface +class BLRPrinter : public Firebird::StackIface { public: BLRPrinter(const unsigned char* blr, size_t length) : @@ -144,7 +144,7 @@ public: }; -class TraceSQLStatementImpl : public Firebird::StackIface +class TraceSQLStatementImpl : public Firebird::StackIface { public: TraceSQLStatementImpl(const dsql_req* stmt, PerformanceInfo* perf) : @@ -162,7 +162,7 @@ public: virtual const char* FB_CARG getTextUTF8(); private: - class DSQLParamsImpl : public Firebird::StackIface + class DSQLParamsImpl : public Firebird::StackIface { public: DSQLParamsImpl(Firebird::MemoryPool& pool, const Firebird::Array* params) : @@ -188,7 +188,7 @@ private: }; -class TraceFailedSQLStatement : public Firebird::StackIface +class TraceFailedSQLStatement : public Firebird::StackIface { public: TraceFailedSQLStatement(Firebird::string& text) : @@ -208,7 +208,7 @@ private: }; -class TraceContextVarImpl : public Firebird::StackIface +class TraceContextVarImpl : public Firebird::StackIface { public: TraceContextVarImpl(const char* ns, const char* name, const char* value) : @@ -227,7 +227,7 @@ private: const char* const m_value; }; -class TraceProcedureImpl : public Firebird::StackIface +class TraceProcedureImpl : public Firebird::StackIface { public: TraceProcedureImpl(jrd_req* request, PerformanceInfo* perf) : @@ -245,7 +245,7 @@ public: virtual PerformanceInfo* FB_CARG getPerf() { return m_perf; }; private: - class JrdParamsImpl : public Firebird::StackIface + class JrdParamsImpl : public Firebird::StackIface { public: JrdParamsImpl(Firebird::MemoryPool& pool, jrd_req* request, const ValueListNode* params) : @@ -271,7 +271,7 @@ private: }; -class TraceTriggerImpl : public Firebird::StackIface +class TraceTriggerImpl : public Firebird::StackIface { public: TraceTriggerImpl(const jrd_req* trig, SSHORT which, PerformanceInfo* perf) : @@ -293,7 +293,7 @@ private: }; -class TraceServiceImpl : public Firebird::StackIface +class TraceServiceImpl : public Firebird::StackIface { public: TraceServiceImpl(const Service* svc) : @@ -331,7 +331,7 @@ private: }; -class TraceInitInfoImpl : public Firebird::StackIface +class TraceInitInfoImpl : public Firebird::StackIface { public: TraceInitInfoImpl(const Firebird::TraceSession& session, const Attachment* att, diff --git a/src/plugins/udr_engine/UdrEngine.cpp b/src/plugins/udr_engine/UdrEngine.cpp index 3399e70cbb..66e1685e24 100644 --- a/src/plugins/udr_engine/UdrEngine.cpp +++ b/src/plugins/udr_engine/UdrEngine.cpp @@ -808,10 +808,9 @@ static Firebird::UnloadDetector unloadDetector; extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) { - IPlugin* plugin = master->getPluginInterface(); - plugin->registerPlugin(PluginType::ExternalEngine, "UDR", &factory); - plugin->setModuleCleanup(&unloadDetector); - plugin->release(); + PluginInterface pi; + pi->registerPlugin(PluginType::ExternalEngine, "UDR", &factory); + pi->setModuleCleanup(&unloadDetector); libraryName->assign("fbclient"); ModuleLoader::doctorModuleExtension(libraryName); diff --git a/src/remote/client/interface.cpp b/src/remote/client/interface.cpp index e1012f1d3a..50ad3a8aa8 100644 --- a/src/remote/client/interface.cpp +++ b/src/remote/client/interface.cpp @@ -497,10 +497,7 @@ namespace { void registerRedirector(Firebird::IPlugin* iPlugin) { - remoteFactory->addRef(); iPlugin->registerPlugin(Firebird::PluginType::Provider, "Remote", &remoteFactory); - - loopbackFactory->addRef(); iPlugin->registerPlugin(Firebird::PluginType::Provider, "Loopback", &loopbackFactory); Auth::registerLegacyClient(iPlugin); @@ -640,7 +637,9 @@ Firebird::IAttachment* Provider::attach(Status* status, const char* filename, init(status, port, op_attach, expanded_name, newDpb); - return new Attachment(port->port_context); + Firebird::IAttachment* a = new Attachment(port->port_context); + a->addRef(); + return a; } catch (const Exception& ex) { @@ -993,7 +992,9 @@ Firebird::IRequest* Attachment::compileRequest(Status* status, message->msg_address = NULL; } - return new Request(request); + Firebird::IRequest* r = new Request(request); + r->addRef(); + return r; } catch (const Exception& ex) { @@ -1071,7 +1072,9 @@ IBlob* Attachment::createBlob(Status* status, ITransaction* apiTra, ISC_QUAD* bl blob->rbl_next = transaction->rtr_blobs; transaction->rtr_blobs = blob; - return new Blob(blob); + Firebird::IBlob* b = new Blob(blob); + b->addRef(); + return b; } catch (const Exception& ex) { @@ -1119,7 +1122,9 @@ Firebird::IAttachment* Provider::create(Status* status, const char* filename, init(status, port, op_create, expanded_name, newDpb); - return new Attachment(rdb); + Firebird::IAttachment* a = new Attachment(rdb); + a->addRef(); + return a; } catch (const Exception& ex) { @@ -1454,7 +1459,9 @@ Firebird::IStatement* Attachment::allocateStatement(Status* status) statement->rsr_next = rdb->rdb_sql_requests; rdb->rdb_sql_requests = statement; - return new Statement(statement); + Firebird::IStatement* s = new Statement(statement); + s->addRef(); + return s; } catch (const Exception& ex) { @@ -1646,7 +1653,9 @@ Firebird::ITransaction* Statement::execute(Status* status, Firebird::ITransactio { transaction = make_transaction(rdb, packet->p_resp.p_resp_object); statement->rsr_rtr = transaction; - return new Transaction(transaction); + Firebird::ITransaction* t = new Transaction(transaction); + t->addRef(); + return t; } } catch (const Exception& ex) @@ -1832,7 +1841,9 @@ Firebird::ITransaction* Attachment::execute(Status* status, Firebird::ITransacti else if (!transaction && packet->p_resp.p_resp_object) { transaction = make_transaction(rdb, packet->p_resp.p_resp_object); - return new Transaction(transaction); + Firebird::ITransaction* t = new Transaction(transaction); + t->addRef(); + return t; } } catch (const Exception& ex) @@ -2946,7 +2957,9 @@ IBlob* Attachment::openBlob(Status* status, ITransaction* apiTra, ISC_QUAD* id, blob->rbl_next = transaction->rtr_blobs; transaction->rtr_blobs = blob; - return new Blob(blob); + Firebird::IBlob* b = new Blob(blob); + b->addRef(); + return b; } catch (const Exception& ex) { @@ -3247,7 +3260,9 @@ Firebird::IEvents* Attachment::queEvents(Status* status, Firebird::EventCallback send_packet(port, packet); receive_response(status, rdb, packet); - return new Events(rem_event); + Firebird::IEvents* rc = new Events(rem_event); + rc->addRef(); + return rc; } catch (const Exception& ex) { @@ -3453,7 +3468,9 @@ Firebird::ITransaction* Attachment::reconnectTransaction(Status* status, send_and_receive(status, rdb, packet); - return new Transaction(make_transaction(rdb, packet->p_resp.p_resp_object)); + Firebird::ITransaction* t = new Transaction(make_transaction(rdb, packet->p_resp.p_resp_object)); + t->addRef(); + return t; } catch (const Exception& ex) { @@ -3824,7 +3841,9 @@ Firebird::IService* Provider::attachSvc(Status* status, const char* service, init(status, port, op_service_attach, expanded_name, newSpb); - return new Service(rdb); + Firebird::IService* s = new Service(rdb); + s->addRef(); + return s; } catch (const Exception& ex) { @@ -4178,7 +4197,9 @@ Firebird::ITransaction* Attachment::startTransaction(Status* status, send_and_receive(status, rdb, packet); - return new Transaction(make_transaction(rdb, packet->p_resp.p_resp_object)); + Firebird::ITransaction* t = new Transaction(make_transaction(rdb, packet->p_resp.p_resp_object)); + t->addRef(); + return t; } catch (const Exception& ex) { diff --git a/src/utilities/gsec/gsec.cpp b/src/utilities/gsec/gsec.cpp index fa1063bce7..d9301a5a44 100644 --- a/src/utilities/gsec/gsec.cpp +++ b/src/utilities/gsec/gsec.cpp @@ -136,7 +136,7 @@ int gsec(Firebird::UtilSvc* uSvc) tsec* tdsec = &tsecInstance; tsec::putSpecific(tdsec); - Auth::UserData u; + Auth::StackUserData u; tdsec->tsec_user_data = &u; try { @@ -252,7 +252,7 @@ int gsec(Firebird::UtilSvc* uSvc) fb_assert(user_data->trustedUser.entered()); if (user_data->trustedUser.entered()) { - class GsecInfo : public Firebird::StackIface + class GsecInfo : public Firebird::StackIface { public: GsecInfo(const char* pTrustedUser, const char* pRole, int pTrustedRole, @@ -334,7 +334,7 @@ int gsec(Firebird::UtilSvc* uSvc) } } - class Display : public Firebird::StackIface + class Display : public Firebird::StackIface { public: Display(tsec* t) diff --git a/src/utilities/ntrace/traceplugin.cpp b/src/utilities/ntrace/traceplugin.cpp index 5a9e459441..7a1c78d631 100644 --- a/src/utilities/ntrace/traceplugin.cpp +++ b/src/utilities/ntrace/traceplugin.cpp @@ -114,7 +114,6 @@ static Firebird::UnloadDetector unloadDetector; void registerTrace(Firebird::IPlugin* iPlugin) { - traceFactory->addRef(); iPlugin->registerPlugin(Firebird::PluginType::Trace, "fbtrace", &traceFactory); iPlugin->setModuleCleanup(&unloadDetector); } @@ -122,7 +121,6 @@ void registerTrace(Firebird::IPlugin* iPlugin) extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) { - Firebird::IPlugin* pi = master->getPluginInterface(); + Firebird::PluginInterface pi(master); registerTrace(pi); - pi->release(); } diff --git a/src/yvalve/MasterImplementation.cpp b/src/yvalve/MasterImplementation.cpp index f24df0a023..92c4892604 100644 --- a/src/yvalve/MasterImplementation.cpp +++ b/src/yvalve/MasterImplementation.cpp @@ -46,7 +46,7 @@ namespace Firebird { -class MasterImplementation : public StackIface +class MasterImplementation : public StackIface { public: Status* FB_CARG getStatusInstance(); @@ -60,17 +60,12 @@ public: // getStatusInstance() // -class UserStatus : public Firebird::StdIface +class UserStatus : public Firebird::DisposeIface { private: - int FB_CARG release() + void FB_CARG dispose() { - if (--refCounter == 0) - { - delete this; - return 0; - } - return 1; + delete this; } }; @@ -87,7 +82,6 @@ IPlugin* FB_CARG MasterImplementation::getPluginInterface() { static Static manager; - manager->addRef(); return &manager; } @@ -460,7 +454,7 @@ THREAD_ENTRY_DECLARE TimerEntry::timeThread(THREAD_ENTRY_PARAM) } // namespace -class TimerImplementation : public StackIface +class TimerImplementation : public StackIface { public: void FB_CARG start(ITimer* timer, TimerDelay microSeconds) @@ -510,7 +504,6 @@ ITimerControl* FB_CARG MasterImplementation::getTimerControl() { static Static timer; - timer->addRef(); return &timer; } @@ -530,6 +523,5 @@ Firebird::IMaster* ISC_EXPORT fb_get_master_interface() { static Firebird::Static master; - master->addRef(); return &master; } diff --git a/src/yvalve/PluginManager.cpp b/src/yvalve/PluginManager.cpp index 78a038fd06..1b4f87cfe0 100644 --- a/src/yvalve/PluginManager.cpp +++ b/src/yvalve/PluginManager.cpp @@ -210,7 +210,9 @@ namespace { if (p) { - return new ConfigParameterAccess(this, p); + IConfigParameter* rc = new ConfigParameterAccess(this, p); + rc->addRef(); + return rc; } return NULL; @@ -221,7 +223,9 @@ namespace { if (par && par->sub.hasData()) { - return new ConfigAccess(par->sub); + IConfig* rc = new ConfigAccess(par->sub); + rc->addRef(); + return rc; } return NULL; @@ -323,17 +327,17 @@ namespace for (unsigned int i = 0; i < regPlugins.getCount(); ++i) { - regPlugins[i].factory->release(); + regPlugins[i].factory->dispose(); } - if (cleanup.hasData()) + if (cleanup) { cleanup->doClean(); } } Firebird::AutoPtr module; - Firebird::RefPtr cleanup; + Firebird::IModuleCleanup* cleanup; HalfStaticArray regPlugins; PluginModule* next; PluginModule** prev; @@ -406,7 +410,9 @@ namespace if (defaultConfig.hasData()) { const ConfigFile::Parameter* p = defaultConfig->findParameter("Config"); - return new ConfigAccess(p ? findConfig("Config", p->value.c_str()) : RefPtr(NULL)); + IConfig* rc = new ConfigAccess(p ? findConfig("Config", p->value.c_str()) : RefPtr(NULL)); + rc->addRef(); + return rc; } PluginInterface pi; @@ -479,10 +485,11 @@ namespace Plugin* ConfiguredPlugin::factory(IFirebirdConf* firebirdConf) { - FactoryParameter* par = new FactoryParameter(this, firebirdConf); + RefPtr par(new FactoryParameter(this, firebirdConf)); Plugin* plugin = module->getPlugin(regPlugin).factory->createPlugin(par); if (plugin) { + par->addRef(); plugin->owner(par); } return plugin; @@ -630,7 +637,7 @@ namespace PathName currentName; RefPtr currentPlugin; // Missing data in this field indicates EOF - IFirebirdConf* firebirdConf; + RefPtr firebirdConf; AutoPtr masterInterface; RefPtr loadModule(const PathName& modName); @@ -845,8 +852,10 @@ IPluginSet* FB_CARG PluginManager::getPlugins(unsigned int interfaceType, const { MutexLockGuard g(plugins->mutex); - return new PluginSet(interfaceType, namesList, desiredVersion, + IPluginSet* rc = new PluginSet(interfaceType, namesList, desiredVersion, missingFunctionClass, firebirdConf); + rc->addRef(); + return rc; } @@ -878,7 +887,9 @@ void FB_CARG PluginManager::releasePlugin(Plugin* plugin) IConfig* FB_CARG PluginManager::getConfig(const char* filename) { - return new ConfigAccess(RefPtr(FB_NEW(*getDefaultMemoryPool()) ConfigFile(filename, 0))); + IConfig* rc = new ConfigAccess(RefPtr(FB_NEW(*getDefaultMemoryPool()) ConfigFile(filename, 0))); + rc->addRef(); + return rc; } diff --git a/src/yvalve/PluginManager.h b/src/yvalve/PluginManager.h index fcde686371..c127dfa20e 100644 --- a/src/yvalve/PluginManager.h +++ b/src/yvalve/PluginManager.h @@ -38,7 +38,7 @@ namespace Firebird { -class PluginManager : public StackIface +class PluginManager : public StackIface { public: IPluginSet* FB_CARG getPlugins(unsigned int interfaceType, const char* namesList, diff --git a/src/yvalve/alt.cpp b/src/yvalve/alt.cpp index 3ef2a75602..d510931835 100644 --- a/src/yvalve/alt.cpp +++ b/src/yvalve/alt.cpp @@ -857,7 +857,7 @@ ISC_STATUS API_ROUTINE isc_add_user(ISC_STATUS* status, const USER_SEC_DATA* inp * Return > 0 if any error occurs. * **************************************/ - Auth::UserData userInfo; + Auth::StackUserData userInfo; userInfo.op = ADD_OPER; Firebird::string work; @@ -926,7 +926,7 @@ ISC_STATUS API_ROUTINE isc_delete_user(ISC_STATUS* status, const USER_SEC_DATA* * Return > 0 if any error occurs. * **************************************/ - Auth::UserData userInfo; + Auth::StackUserData userInfo; userInfo.op = DEL_OPER; Firebird::string work; @@ -968,7 +968,7 @@ ISC_STATUS API_ROUTINE isc_modify_user(ISC_STATUS* status, const USER_SEC_DATA* * Return > 0 if any error occurs. * **************************************/ - Auth::UserData userInfo; + Auth::StackUserData userInfo; userInfo.op = MOD_OPER; Firebird::string work; diff --git a/src/yvalve/why.cpp b/src/yvalve/why.cpp index 436c925f26..720ca6189a 100644 --- a/src/yvalve/why.cpp +++ b/src/yvalve/why.cpp @@ -1024,7 +1024,7 @@ const USHORT DESCRIBE_BUFFER_SIZE = 1024; // size of buffer used in isc_dsql_de namespace { // Status: Provides correct status vector for operation and init() it. - class StatusVector : public StackIface + class StatusVector : public StackIface { public: explicit StatusVector(ISC_STATUS* v) throw()