From 233093cee4f249c88adf1a00c0ed9ffc25df9a85 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Sun, 16 Jan 2011 02:16:15 +0000 Subject: [PATCH] Misc --- builds/install/misc/firebird.conf.in | 2 +- doc/README.fb_shutdown | 2 +- src/common/ThreadStart.cpp | 3 --- src/common/classes/ImplementHelper.h | 2 +- src/common/config/config.cpp | 2 +- src/common/unicode_util.cpp | 4 +-- src/include/ProviderInterface.h | 4 +-- src/jrd/ExtEngineManager.cpp | 2 +- src/jrd/blb.cpp | 16 +++--------- src/jrd/jrd.cpp | 6 +++-- src/jrd/tra.h | 5 ++-- src/jrd/trace/TraceManager.cpp | 5 ++-- src/jrd/trace/TraceManager.h | 6 +++-- src/plugins/udr_engine/UdrEngine.cpp | 13 +++++++--- src/remote/client/interface.cpp | 33 +++++------------------- src/remote/client/interface.h | 5 +++- src/remote/remote.cpp | 2 +- src/utilities/ntrace/PluginLogWriter.h | 1 + src/utilities/ntrace/TracePluginImpl.cpp | 2 +- src/yvalve/MasterImplementation.cpp | 8 +++--- src/yvalve/PluginManager.cpp | 18 ++++++++----- 21 files changed, 62 insertions(+), 79 deletions(-) diff --git a/builds/install/misc/firebird.conf.in b/builds/install/misc/firebird.conf.in index ee09ecc03a..7e813eaeb8 100644 --- a/builds/install/misc/firebird.conf.in +++ b/builds/install/misc/firebird.conf.in @@ -356,7 +356,7 @@ # # Type: string -# AuthServer and AuthClient determine what uthentication methods will be used +# AuthServer and AuthClient determine what authentication methods will be used # by network server and client redirector. For non-windows systems default # for both is Legacy_Auth. # diff --git a/doc/README.fb_shutdown b/doc/README.fb_shutdown index 5725200ba9..39e29ab2a5 100644 --- a/doc/README.fb_shutdown +++ b/doc/README.fb_shutdown @@ -43,7 +43,7 @@ to callback function. Call mask can have the following values: fb_shut_confirmation - callback function may return non-zero value to abort shutdown fb_shut_preproviders - callback function will be called before shutting down engine fb_shut_postproviders - callback function will be called after shutting down engine -fb_shut_finish - final step, callback function may wait for some activity to be treminated +fb_shut_finish - final step, callback function may wait for some activity to be terminated or ORed combination of them (to make same function be called in required cases). Callback function has 3 parameters - reason of shutdown, actual value of mask with which it was diff --git a/src/common/ThreadStart.cpp b/src/common/ThreadStart.cpp index 3d40f4e7e1..cc59ba1f3e 100644 --- a/src/common/ThreadStart.cpp +++ b/src/common/ThreadStart.cpp @@ -37,8 +37,6 @@ #include "../common/isc_s_proto.h" #include "../common/gdsassert.h" - - #ifdef WIN_NT #include #include @@ -139,7 +137,6 @@ void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Handl pthread_attr_t pattr; int state; - #if defined (LINUX) || defined (FREEBSD) if (state = pthread_create(&thread, NULL, THREAD_ENTRYPOINT, THREAD_ARG)) Firebird::system_call_failed::raise("pthread_create", state); diff --git a/src/common/classes/ImplementHelper.h b/src/common/classes/ImplementHelper.h index 9dcbee7d86..c6e76095de 100644 --- a/src/common/classes/ImplementHelper.h +++ b/src/common/classes/ImplementHelper.h @@ -261,7 +261,7 @@ private: void getPlugin() { - currentPlugin = (P*)(pluginSet->plugin()); + currentPlugin = (P*) pluginSet->plugin(); } }; diff --git a/src/common/config/config.cpp b/src/common/config/config.cpp index e48fdb0278..3f33f4fb5c 100644 --- a/src/common/config/config.cpp +++ b/src/common/config/config.cpp @@ -662,7 +662,7 @@ bool Config::getMultiClientServer() const char* Config::getPlugins(unsigned int type) { - switch(type) + switch (type) { case Firebird::PluginType::Provider: return (const char*) getDefaultConfig()->values[KEY_PLUG_PROVIDERS]; diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp index 418e6b2ffe..32b8214fdc 100644 --- a/src/common/unicode_util.cpp +++ b/src/common/unicode_util.cpp @@ -779,10 +779,8 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const Firebird::string& icuVersion, ObjectsArray versions; getVersions(configInfo, versions); - if (!versions.getCount()) - { + if (versions.isEmpty()) gds__log("No versions"); - } string version = icuVersion.isEmpty() ? versions[0] : icuVersion; if (version == "default") diff --git a/src/include/ProviderInterface.h b/src/include/ProviderInterface.h index 4f103801e4..a435254a31 100644 --- a/src/include/ProviderInterface.h +++ b/src/include/ProviderInterface.h @@ -67,9 +67,9 @@ public: virtual void FB_CARG getInfo(Firebird::Status* status, unsigned int itemsLength, const unsigned char* items, unsigned int bufferLength, unsigned char* buffer) = 0; - virtual unsigned int FB_CARG getSegment(Firebird::Status* status, unsigned int length, + virtual unsigned int FB_CARG getSegment(Firebird::Status* status, unsigned int length, unsigned char* buffer) = 0; // returns real length - virtual void FB_CARG putSegment(Firebird::Status* status, unsigned int length, + virtual void FB_CARG putSegment(Firebird::Status* status, unsigned int length, const unsigned char* buffer) = 0; virtual void FB_CARG cancel(Firebird::Status* status) = 0; virtual void FB_CARG close(Firebird::Status* status) = 0; diff --git a/src/jrd/ExtEngineManager.cpp b/src/jrd/ExtEngineManager.cpp index 123e2a0030..e660be57ca 100644 --- a/src/jrd/ExtEngineManager.cpp +++ b/src/jrd/ExtEngineManager.cpp @@ -659,7 +659,7 @@ When engine is released, it does dlclose() plugin module (libudr_engine.so), but that module is not actually unloaded - because UDR module (libudrcpp_example.so) is using symbols from plugin module, therefore raising plugin module's reference count. UDR module can be unloaded only from plugin module's global variable (ModuleMap modules) dtor, -which is not called as long as plugin module is not inloaded. As the result all this will be +which is not called as long as plugin module is not unloaded. As the result all this will be unloaded only on program exit, causing at that moment AV if this code is active: it happens that ~ModuleMap dlcloses itself. diff --git a/src/jrd/blb.cpp b/src/jrd/blb.cpp index 611bea152f..4ee5da84d8 100644 --- a/src/jrd/blb.cpp +++ b/src/jrd/blb.cpp @@ -2592,20 +2592,10 @@ static void move_to_string(thread_db* tdbb, dsc* fromDesc, dsc* toDesc) } +// Release a blob and associated blocks. Among other things, disconnect it from the transaction. +// However, if purge_flag is false, then only release the associated blocks. void blb::destroy(blb* blob, const bool purge_flag) { -/************************************** - * - * r e l e a s e _ b l o b - * - ************************************** - * - * Functional description - * Release a blob and associated blocks. Among other things, - * disconnect it from the transaction. However, if purge_flag - * is false, then only release the associated blocks. - * - **************************************/ jrd_tra* const transaction = blob->blb_transaction; // Disconnect blob from transaction block. @@ -2646,7 +2636,7 @@ void blb::destroy(blb* blob, const bool purge_flag) blob->blb_transaction->getBlobSpace()->releaseSpace(blob->blb_temp_offset, blob->blb_temp_size); } - --(blob->refCounter); + --blob->refCounter; delete blob; } diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index cb4cf77c9e..2a36cf48e5 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -3725,7 +3725,8 @@ void Provider::shutdown(Status* status, unsigned int timeout, const int /*reason try { CounterGuard guard(shutCounter); -/* + + /*** if (unloading) { return; @@ -3738,7 +3739,8 @@ void Provider::shutdown(Status* status, unsigned int timeout, const int /*reason { return; } -*/ + ***/ + ThreadContextHolder tdbb; ULONG attach_count, database_count, svc_count; diff --git a/src/jrd/tra.h b/src/jrd/tra.h index ca23c0f1c4..292e60b5ec 100644 --- a/src/jrd/tra.h +++ b/src/jrd/tra.h @@ -194,11 +194,10 @@ public: { if (transaction) { - --(transaction->refCounter); + --transaction->refCounter; + if (!dbb || transaction->tra_outer) - { delete transaction; - } else { MemoryPool* const pool = transaction->tra_pool; diff --git a/src/jrd/trace/TraceManager.cpp b/src/jrd/trace/TraceManager.cpp index d8b07520ac..95f4692efc 100644 --- a/src/jrd/trace/TraceManager.cpp +++ b/src/jrd/trace/TraceManager.cpp @@ -53,6 +53,7 @@ namespace virtual int FB_CARG noEvent() { static bool flagFirst = true; + if (flagFirst) { flagFirst = false; @@ -154,7 +155,7 @@ void TraceManager::load_plugins() init_factories = true; for (PluginsSet traceItr(PluginType::Trace, FB_TRACE_PLUGIN_VERSION); - traceItr.hasData(); traceItr.next()) + traceItr.hasData(); traceItr.next()) { FactoryInfo info; info.factory = traceItr.plugin(); @@ -241,7 +242,7 @@ void TraceManager::update_session(const TraceSession& session) } } - for (FactoryInfo* info = factories->begin(); info < factories->end(); ++info) + for (FactoryInfo* info = factories->begin(); info != factories->end(); ++info) { TraceInitInfoImpl attachInfo(session, attachment, filename); LocalStatus status; diff --git a/src/jrd/trace/TraceManager.h b/src/jrd/trace/TraceManager.h index 8a7aa4bc6f..714fe01d97 100644 --- a/src/jrd/trace/TraceManager.h +++ b/src/jrd/trace/TraceManager.h @@ -150,21 +150,23 @@ private: TraceFactory* factory; char name[MAXPATHLEN]; }; + class Factories : public Firebird::Array { public: Factories(Firebird::MemoryPool& p) : Firebird::Array(p) { } + ~Factories() { Firebird::PluginInterface pi; + for (unsigned int i = 0; i < getCount(); ++i) - { pi->releasePlugin(getElement(i).factory); - } } }; + static Firebird::GlobalPtr factories; static Firebird::GlobalPtr init_factories_mtx; static volatile bool init_factories; diff --git a/src/plugins/udr_engine/UdrEngine.cpp b/src/plugins/udr_engine/UdrEngine.cpp index d02b7592d0..febfb93fc9 100644 --- a/src/plugins/udr_engine/UdrEngine.cpp +++ b/src/plugins/udr_engine/UdrEngine.cpp @@ -90,13 +90,16 @@ public: { // this plugin is not ready to support different configurations // therefore keep legacy approach + IConfigParameter* icp = NULL; + for (int n = 0; (icp = defaultConfig->findPos("path", n)); ++n) { PathName newPath(icp->value()); icp->release(); bool found = false; + for (ObjectsArray::iterator i = paths->begin(); i != paths->end(); ++i) { if (*i == newPath) @@ -779,7 +782,7 @@ void FB_CALL Engine::dispose(Error* /*error*/) //-------------------------------------- -/* +/*** class ExternalEngineFactoryImpl : public ExternalEngineFactory { public: @@ -796,7 +799,8 @@ public: error->addString(msg, strlen(msg)); return NULL; } - */ +***/ + class ExternalEngineFactoryImpl : public SimpleFactory { } factory; @@ -807,7 +811,8 @@ extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) Firebird::IPlugin* plugin = master->getPluginInterface(); plugin->registerPlugin(Firebird::PluginType::ExternalEngine, "UDR", &factory); plugin->release(); -/* + + /*** if (plugin->getLibraryName()) libraryName->assign(plugin->getLibraryName()); libraryModule = ModuleLoader::loadModule(libraryName); @@ -823,7 +828,7 @@ extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master) } plugin->setExternalEngineFactory(&factory); - */ + ***/ } diff --git a/src/remote/client/interface.cpp b/src/remote/client/interface.cpp index 6eb73a5742..9f52e8791e 100644 --- a/src/remote/client/interface.cpp +++ b/src/remote/client/interface.cpp @@ -165,9 +165,8 @@ int Blob::release() cancel(&status); } else - { delete this; - } + return 0; } @@ -209,10 +208,12 @@ public: public: Transaction(Rtr* handle) : transaction(handle) { } + Rtr* getTransaction() { return transaction; } + void clear() { transaction = NULL; @@ -226,9 +227,7 @@ private: int Transaction::release() { if (--refCounter != 0) - { return 1; - } if (transaction) { @@ -236,9 +235,7 @@ int Transaction::release() rollback(&status); } else - { delete this; - } return 0; } @@ -287,9 +284,7 @@ private: int Statement::release() { if (--refCounter != 0) - { return 1; - } if (statement) { @@ -297,9 +292,7 @@ int Statement::release() free(&status, DSQL_drop); } else - { delete this; - } return 0; } @@ -331,9 +324,7 @@ private: int Request::release() { if (--refCounter != 0) - { return 1; - } if (rq) { @@ -341,9 +332,7 @@ int Request::release() free(&status); } else - { delete this; - } return 0; } @@ -364,9 +353,7 @@ private: int Events::release() { if (--refCounter != 0) - { return 1; - } if (rvnt) { @@ -374,9 +361,7 @@ int Events::release() cancel(&status); } else - { delete this; - } return 0; } @@ -410,6 +395,7 @@ public: public: Attachment(Rdb* handle) : rdb(handle) { } + Rdb* getRdb() { return rdb; @@ -422,9 +408,7 @@ private: int Attachment::release() { if (--refCounter != 0) - { return 1; - } if (rdb) { @@ -432,9 +416,7 @@ int Attachment::release() detach(&status); } else - { delete this; - } return 0; } @@ -461,9 +443,7 @@ private: int Service::release() { if (--refCounter != 0) - { return 1; - } if (rdb) { @@ -471,9 +451,7 @@ int Service::release() detach(&status); } else - { delete this; - } return 0; } @@ -502,6 +480,7 @@ public: delete this; return 0; } + return 1; } @@ -5667,7 +5646,7 @@ static void init(Status* status, if (n && n->cstr_length && authItr.hasData()) { // if names match, do not change instance - if (strlen(authItr.name()) == n->cstr_length && + if (strlen(authItr.name()) == n->cstr_length && memcmp(authItr.name(), n->cstr_address, n->cstr_length) == 0) { n = NULL; diff --git a/src/remote/client/interface.h b/src/remote/client/interface.h index a539b7c88b..1648a61592 100644 --- a/src/remote/client/interface.h +++ b/src/remote/client/interface.h @@ -28,7 +28,10 @@ #ifndef REMOTE_CLIENT_INTERFACE_H #define REMOTE_CLIENT_INTERFACE_H -namespace Remote { + +namespace Remote +{ void registerRedirector(Firebird::IPlugin* iPlugin); } + #endif // REMOTE_CLIENT_INTERFACE_H diff --git a/src/remote/remote.cpp b/src/remote/remote.cpp index e59b66601e..2f02488a9e 100644 --- a/src/remote/remote.cpp +++ b/src/remote/remote.cpp @@ -845,7 +845,7 @@ void Rsr::saveException(const Firebird::Exception& ex, bool overwrite) if (!rsr_status) { rsr_status = new Firebird::StatusHolder(); } - + if (overwrite || !rsr_status->getError()) { ISC_STATUS_ARRAY temp; diff --git a/src/utilities/ntrace/PluginLogWriter.h b/src/utilities/ntrace/PluginLogWriter.h index aa6c9fd0b5..62e5339500 100644 --- a/src/utilities/ntrace/PluginLogWriter.h +++ b/src/utilities/ntrace/PluginLogWriter.h @@ -54,6 +54,7 @@ public: ~PluginLogWriter(); virtual size_t write(const void* buf, size_t size); + virtual int release() { if (--refCounter == 0) diff --git a/src/utilities/ntrace/TracePluginImpl.cpp b/src/utilities/ntrace/TracePluginImpl.cpp index 8c29944771..787c407df3 100644 --- a/src/utilities/ntrace/TracePluginImpl.cpp +++ b/src/utilities/ntrace/TracePluginImpl.cpp @@ -2154,7 +2154,7 @@ ntrace_boolean_t TracePluginImpl::trace_service_query(TraceService* service, siz { try { - log_event_service_query(service, send_item_length, send_items, + log_event_service_query(service, send_item_length, send_items, recv_item_length, recv_items, query_result); return true; } diff --git a/src/yvalve/MasterImplementation.cpp b/src/yvalve/MasterImplementation.cpp index 78da55709c..1f703c5971 100644 --- a/src/yvalve/MasterImplementation.cpp +++ b/src/yvalve/MasterImplementation.cpp @@ -93,12 +93,12 @@ void FB_CARG MasterImplementation::upgradeInterface(Interface* toUpgrade, if (toUpgrade->version() >= desiredVersion) return; - CVirtualClass* target = (CVirtualClass*)toUpgrade; + CVirtualClass* target = (CVirtualClass*) toUpgrade; FunctionPtr* newTab = NULL; - if (!functionMap->get((U_IPTR)(target->vTab), newTab)) + if (!functionMap->get((U_IPTR) target->vTab, newTab)) { - CVirtualClass* miss = (CVirtualClass*)missingFunctionClass; + CVirtualClass* miss = (CVirtualClass*) missingFunctionClass; newTab = FB_NEW(*getDefaultMemoryPool()) FunctionPtr[desiredVersion]; for (int i = 0; i < toUpgrade->version(); ++i) @@ -106,7 +106,7 @@ void FB_CARG MasterImplementation::upgradeInterface(Interface* toUpgrade, for (int j = toUpgrade->version(); j < desiredVersion; ++j) newTab[j] = miss->vTab[0]; - functionMap->put((U_IPTR)(target->vTab), newTab); + functionMap->put((U_IPTR) target->vTab, newTab); } target->vTab = newTab; diff --git a/src/yvalve/PluginManager.cpp b/src/yvalve/PluginManager.cpp index 8cf06f958b..b9374e768e 100644 --- a/src/yvalve/PluginManager.cpp +++ b/src/yvalve/PluginManager.cpp @@ -142,12 +142,12 @@ namespace if (--refCounter == 0) { if (cf) - { cf->release(); - } + delete this; return 0; } + return 1; } @@ -200,6 +200,7 @@ namespace delete this; return 0; } + return 1; } @@ -213,6 +214,7 @@ namespace addRef(); return new ConfigParameterAccess(this, p); } + return NULL; } }; @@ -220,9 +222,8 @@ namespace IConfig* ConfigParameterAccess::sub() { if (par && par->sub.hasData()) - { return new ConfigAccess(par->sub); - } + return NULL; } @@ -231,6 +232,7 @@ namespace RegisteredPlugin(PluginsFactory* f, const char* nm, unsigned int t) : factory(f), name(nm), type(t) { } + RegisteredPlugin() : factory(NULL), name(NULL), type(0) { } @@ -364,6 +366,7 @@ namespace delete this; return 0; } + return 1; } @@ -495,6 +498,7 @@ namespace delete this; return 0; } + return 1; } @@ -509,6 +513,7 @@ namespace AutoPtr masterInterface; RefPtr loadModule(const PathName& modName); + void loadError(const Arg::StatusVector& error) { iscLogStatus("PluginSet", error.value()); @@ -576,7 +581,7 @@ namespace RegisteredPlugin* r = m->findPlugin(interfaceType, regName); if (! r) { - gds__log("Misconfigured: module %s does not contain plugin %s type %d", + gds__log("Misconfigured: module %s does not contain plugin %s type %d", curModule.c_str(), regName.c_str(), interfaceType); continue; } @@ -586,7 +591,7 @@ namespace currentPlugin = new ConfiguredPlugin(m, r, conf, plugConfigFile, currentName); currentPlugin->release(); // std interface is created with refCounter == 1 - // cause currentPlugin holds refernce itself, that 1 should be released() here + // cause currentPlugin holds reference itself, that 1 should be released() here plugins->put(MapKey(interfaceType, currentName), currentPlugin); return; @@ -698,6 +703,7 @@ void FB_CARG PluginManager::releasePlugin(Plugin* plugin) MutexLockGuard g(plugins->mutex); Interface* parent = plugin->owner(NULL); + if (plugin->release() == 0) { fb_assert(parent);