| 1061 | |
| 1062 | |
| 1063 | void PluginManager::registerPluginFactory(unsigned int interfaceType, const char* defaultName, IPluginFactory* factory) |
| 1064 | { |
| 1065 | try |
| 1066 | { |
| 1067 | MutexLockGuard g(plugins->mutex, FB_FUNCTION); |
| 1068 | |
| 1069 | if (!current) |
| 1070 | { |
| 1071 | // not good time to call this function - ignore request |
| 1072 | gds__log("Unexpected call to register plugin %s, type %d - ignored\n", defaultName, interfaceType); |
| 1073 | return; |
| 1074 | } |
| 1075 | |
| 1076 | unsigned int r = current->addPlugin(RegisteredPlugin(factory, defaultName, interfaceType)); |
| 1077 | |
| 1078 | if (current == builtin) |
| 1079 | { |
| 1080 | PathName plugConfigFile = fb_utils::getPrefix(IConfigManager::DIR_PLUGINS, defaultName); |
| 1081 | changeExtension(plugConfigFile, "conf"); |
| 1082 | |
| 1083 | ConfiguredPlugin* p = FB_NEW ConfiguredPlugin(RefPtr<PluginModule>(builtin), r, |
| 1084 | findInPluginsConf("Plugin", defaultName), plugConfigFile, defaultName); |
| 1085 | p->addRef(); // Will never be unloaded |
| 1086 | plugins->put(MapKey(interfaceType, defaultName), p); |
| 1087 | } |
| 1088 | } |
| 1089 | catch(const Exception& ex) |
| 1090 | { |
| 1091 | // looks like something gone seriously wrong - therefore add more error handling here |
| 1092 | try |
| 1093 | { |
| 1094 | FbLocalStatus ls; |
| 1095 | ex.stuffException(&ls); |
| 1096 | char text[256]; |
| 1097 | UtilInterfacePtr()->formatStatus(text, sizeof(text), &ls); |
| 1098 | Syslog::Record(Syslog::Error, text); |
| 1099 | |
| 1100 | iscLogException("Plugin registration error", ex); |
| 1101 | } |
| 1102 | catch(const BadAlloc&) |
| 1103 | { |
| 1104 | Syslog::Record(Syslog::Error, "Plugin registration error - out of memory"); |
| 1105 | } |
| 1106 | catch(...) |
| 1107 | { |
| 1108 | Syslog::Record(Syslog::Error, "Double fault during plugin registration"); |
| 1109 | } |
| 1110 | |
| 1111 | #ifdef DEV_BUILD |
| 1112 | abort(); |
| 1113 | #endif |
| 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | |
| 1118 | void PluginManager::registerModule(IPluginModule* cleanup) |
no test coverage detected