X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffactory_filter.cpp;h=39152028b21f3975eb06240e22e984395db790f9;hb=97a7133fc8325a08560a0326f80459ec31f516f6;hp=071a7d1b056525f920d5b7f86ebf859f43762ffd;hpb=8ced8e7b5de3ecba12ac68ce5c5e8cddf40d800f;p=metaproxy-moved-to-github.git diff --git a/src/factory_filter.cpp b/src/factory_filter.cpp index 071a7d1..3915202 100644 --- a/src/factory_filter.cpp +++ b/src/factory_filter.cpp @@ -101,15 +101,6 @@ mp::filter::Base* mp::FactoryFilter::create(std::string fi) return (it->second()); } -bool mp::FactoryFilter::have_dl_support() -{ -#if HAVE_DLFCN_H - return true; -#else - return false; -#endif -} - bool mp::FactoryFilter::add_creator_dl(const std::string &fi, const std::string &path) { @@ -118,20 +109,24 @@ bool mp::FactoryFilter::add_creator_dl(const std::string &fi, { return true; } - - std::string full_path = path + "/metaproxy_filter_" + fi + ".so"; - void *dl_handle = dlopen(full_path.c_str(), RTLD_GLOBAL|RTLD_NOW); - if (!dl_handle) - { - const char *dl = dlerror(); - std::cout << "dlopen " << full_path << " failed. dlerror=" << dl << - std::endl; - return false; - } - std::string full_name = "metaproxy_1_filter_" + fi; + void *dl_handle = dlopen(0, RTLD_GLOBAL|RTLD_NOW); void *dlsym_ptr = dlsym(dl_handle, full_name.c_str()); + + if (!dlsym_ptr) + { + std::string full_path = path + "/metaproxy_filter_" + fi + ".so"; + dl_handle = dlopen(full_path.c_str(), RTLD_GLOBAL|RTLD_NOW); + if (!dl_handle) + { + const char *dl = dlerror(); + std::cout << "dlopen " << full_path << " failed. dlerror=" << dl << + std::endl; + return false; + } + dlsym_ptr = dlsym(dl_handle, full_name.c_str()); + } if (!dlsym_ptr) { std::cout << "dlsym " << full_name << " failed\n";