X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffactory_filter.cpp;h=a0c3d6eb294e4c9f2619e10fd9b4238ef8417b74;hb=586d78659d671683f33ec55f4a7d32b28e345ccd;hp=5fec9ddad22bda3123f9cb838c80c048cb4520ec;hpb=73f37c91c144b070020df2f27472c09b62367acf;p=metaproxy-moved-to-github.git diff --git a/src/factory_filter.cpp b/src/factory_filter.cpp index 5fec9dd..a0c3d6e 100644 --- a/src/factory_filter.cpp +++ b/src/factory_filter.cpp @@ -1,5 +1,5 @@ /* This file is part of Metaproxy. - Copyright (C) 2005-2012 Index Data + Copyright (C) Index Data Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -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";