From ad428707d2a52bbe4db21e47c5ebb26e13598484 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 4 Jan 2006 11:55:31 +0000 Subject: [PATCH] Make public yp2_filter_struct non-const. If not, the linker symbol is screwed. Test for double dl-load in FilterFactory. --- src/factory_static.cpp | 4 ++-- src/filter_backend_test.cpp | 4 ++-- src/filter_backend_test.hpp | 4 ++-- src/filter_dl.cpp | 6 +++--- src/filter_factory.cpp | 9 ++++++++- src/filter_frontend_net.cpp | 4 ++-- src/filter_frontend_net.hpp | 4 ++-- src/filter_log.cpp | 4 ++-- src/filter_log.hpp | 4 ++-- src/filter_session_shared.cpp | 4 ++-- src/filter_session_shared.hpp | 4 ++-- src/filter_template.cpp | 4 ++-- src/filter_template.hpp | 4 ++-- src/filter_virt_db.cpp | 4 ++-- src/filter_virt_db.hpp | 4 ++-- src/filter_z3950_client.cpp | 4 ++-- src/filter_z3950_client.hpp | 4 ++-- src/test_filter_factory.cpp | 8 ++++++-- src/test_router_flexml.cpp | 9 ++++++--- 19 files changed, 53 insertions(+), 39 deletions(-) diff --git a/src/factory_static.cpp b/src/factory_static.cpp index ff70983..1f684f6 100644 --- a/src/factory_static.cpp +++ b/src/factory_static.cpp @@ -1,4 +1,4 @@ -/* $Id: factory_static.cpp,v 1.1 2006-01-04 11:19:04 adam Exp $ +/* $Id: factory_static.cpp,v 1.2 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -26,7 +26,7 @@ yp2::FactoryStatic::FactoryStatic(yp2::FilterFactory &factory) { - const struct yp2_filter_struct *buildins[] = { + struct yp2_filter_struct *buildins[] = { &yp2_filter_backend_test, &yp2_filter_frontend_net, &yp2_filter_log, diff --git a/src/filter_backend_test.cpp b/src/filter_backend_test.cpp index d622530..144556e 100644 --- a/src/filter_backend_test.cpp +++ b/src/filter_backend_test.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_backend_test.cpp,v 1.11 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_backend_test.cpp,v 1.12 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -148,7 +148,7 @@ static yp2::filter::Base* filter_creator() } extern "C" { - const struct yp2_filter_struct yp2_filter_backend_test = { + struct yp2_filter_struct yp2_filter_backend_test = { 0, "backend_test", filter_creator diff --git a/src/filter_backend_test.hpp b/src/filter_backend_test.hpp index 66dcc5d..7c2b71e 100644 --- a/src/filter_backend_test.hpp +++ b/src/filter_backend_test.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_backend_test.hpp,v 1.6 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_backend_test.hpp,v 1.7 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -26,7 +26,7 @@ namespace yp2 { } extern "C" { - extern const struct yp2_filter_struct yp2_filter_backend_test; + extern struct yp2_filter_struct yp2_filter_backend_test; } #endif diff --git a/src/filter_dl.cpp b/src/filter_dl.cpp index 04a088e..54c1051 100644 --- a/src/filter_dl.cpp +++ b/src/filter_dl.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_dl.cpp,v 1.2 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_dl.cpp,v 1.3 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -21,7 +21,7 @@ namespace yp2 { void yp2::filter::Filter_dl::process(yp2::Package & package) const { - package.data() = 42; + package.data() = 42; // magic checked in test_filter_factory } static yp2::filter::Base* filter_creator() @@ -30,7 +30,7 @@ static yp2::filter::Base* filter_creator() } extern "C" { - const struct yp2_filter_struct yp2_filter_dl = { + struct yp2_filter_struct yp2_filter_dl = { 0, "dl", filter_creator diff --git a/src/filter_factory.cpp b/src/filter_factory.cpp index a5406bd..6efdc89 100644 --- a/src/filter_factory.cpp +++ b/src/filter_factory.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_factory.cpp,v 1.2 2005-12-10 09:59:10 adam Exp $ +/* $Id: filter_factory.cpp,v 1.3 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -19,6 +19,8 @@ namespace yp2 { class FilterFactory::Rep { typedef std::map CallbackMap; + typedef std::map::iterator + CallbackMapIt; public: friend class FilterFactory; CallbackMap m_fcm; @@ -78,6 +80,11 @@ yp2::filter::Base* yp2::FilterFactory::create(std::string fi) bool yp2::FilterFactory::add_creator_dyn(const std::string &fi, const std::string &path) { + if (m_p->m_fcm.find(fi) != m_p->m_fcm.end()) + { + return true; + } + std::string full_path = path + "/yp2_filter_" + fi + ".so"; void *dl_handle = dlopen(full_path.c_str(), RTLD_GLOBAL|RTLD_NOW); if (!dl_handle) diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index 8aa35a2..bf26441 100644 --- a/src/filter_frontend_net.cpp +++ b/src/filter_frontend_net.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_frontend_net.cpp,v 1.10 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_frontend_net.cpp,v 1.11 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -291,7 +291,7 @@ static yp2::filter::Base* filter_creator() } extern "C" { - const struct yp2_filter_struct yp2_filter_frontend_net = { + struct yp2_filter_struct yp2_filter_frontend_net = { 0, "frontend_net", filter_creator diff --git a/src/filter_frontend_net.hpp b/src/filter_frontend_net.hpp index 0f6abe9..f90d69b 100644 --- a/src/filter_frontend_net.hpp +++ b/src/filter_frontend_net.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_frontend_net.hpp,v 1.9 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_frontend_net.hpp,v 1.10 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -32,7 +32,7 @@ namespace yp2 { } extern "C" { - extern const struct yp2_filter_struct yp2_filter_frontend_net; + extern struct yp2_filter_struct yp2_filter_frontend_net; } #endif diff --git a/src/filter_log.cpp b/src/filter_log.cpp index 4142be7..86ee793 100644 --- a/src/filter_log.cpp +++ b/src/filter_log.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_log.cpp,v 1.10 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_log.cpp,v 1.11 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -104,7 +104,7 @@ static yp2::filter::Base* filter_creator() } extern "C" { - const struct yp2_filter_struct yp2_filter_log = { + struct yp2_filter_struct yp2_filter_log = { 0, "log", filter_creator diff --git a/src/filter_log.hpp b/src/filter_log.hpp index a829d80..2ae395a 100644 --- a/src/filter_log.hpp +++ b/src/filter_log.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_log.hpp,v 1.11 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_log.hpp,v 1.12 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -26,7 +26,7 @@ namespace yp2 { } extern "C" { - extern const struct yp2_filter_struct yp2_filter_log; + extern struct yp2_filter_struct yp2_filter_log; } #endif diff --git a/src/filter_session_shared.cpp b/src/filter_session_shared.cpp index 0936bc0..7a8b4fa 100644 --- a/src/filter_session_shared.cpp +++ b/src/filter_session_shared.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_session_shared.cpp,v 1.3 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_session_shared.cpp,v 1.4 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -257,7 +257,7 @@ static yp2::filter::Base* filter_creator() } extern "C" { - const struct yp2_filter_struct yp2_filter_session_shared = { + struct yp2_filter_struct yp2_filter_session_shared = { 0, "session_shared", filter_creator diff --git a/src/filter_session_shared.hpp b/src/filter_session_shared.hpp index c584467..ff8898d 100644 --- a/src/filter_session_shared.hpp +++ b/src/filter_session_shared.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_session_shared.hpp,v 1.2 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_session_shared.hpp,v 1.3 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -28,7 +28,7 @@ namespace yp2 { } extern "C" { - extern const struct yp2_filter_struct yp2_filter_session_shared; + extern struct yp2_filter_struct yp2_filter_session_shared; } #endif diff --git a/src/filter_template.cpp b/src/filter_template.cpp index 07c0d2a..2aced06 100644 --- a/src/filter_template.cpp +++ b/src/filter_template.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_template.cpp,v 1.3 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_template.cpp,v 1.4 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -49,7 +49,7 @@ static yp2::filter::Base* filter_creator() } extern "C" { - const struct yp2_filter_struct yp2_filter_template = { + struct yp2_filter_struct yp2_filter_template = { 0, "template", filter_creator diff --git a/src/filter_template.hpp b/src/filter_template.hpp index f6b2e38..0b437cb 100644 --- a/src/filter_template.hpp +++ b/src/filter_template.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_template.hpp,v 1.3 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_template.hpp,v 1.4 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -26,7 +26,7 @@ namespace yp2 { } extern "C" { - extern const struct yp2_filter_struct yp2_filter_template; + extern struct yp2_filter_struct yp2_filter_template; } #endif diff --git a/src/filter_virt_db.cpp b/src/filter_virt_db.cpp index 3ba8487..b4427b2 100644 --- a/src/filter_virt_db.cpp +++ b/src/filter_virt_db.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_virt_db.cpp,v 1.16 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_virt_db.cpp,v 1.17 2006-01-04 11:55:31 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -869,7 +869,7 @@ static yp2::filter::Base* filter_creator() } extern "C" { - const struct yp2_filter_struct yp2_filter_virt_db = { + struct yp2_filter_struct yp2_filter_virt_db = { 0, "virt_db", filter_creator diff --git a/src/filter_virt_db.hpp b/src/filter_virt_db.hpp index 9e2991e..d5065b5 100644 --- a/src/filter_virt_db.hpp +++ b/src/filter_virt_db.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_virt_db.hpp,v 1.5 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_virt_db.hpp,v 1.6 2006-01-04 11:55:32 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -29,7 +29,7 @@ namespace yp2 { } extern "C" { - extern const struct yp2_filter_struct yp2_filter_virt_db; + extern struct yp2_filter_struct yp2_filter_virt_db; } #endif diff --git a/src/filter_z3950_client.cpp b/src/filter_z3950_client.cpp index d98a5b7..178a3b8 100644 --- a/src/filter_z3950_client.cpp +++ b/src/filter_z3950_client.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_z3950_client.cpp,v 1.14 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_z3950_client.cpp,v 1.15 2006-01-04 11:55:32 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -332,7 +332,7 @@ static yp2::filter::Base* filter_creator() } extern "C" { - const struct yp2_filter_struct yp2_filter_z3950_client = { + struct yp2_filter_struct yp2_filter_z3950_client = { 0, "z3950_client", filter_creator diff --git a/src/filter_z3950_client.hpp b/src/filter_z3950_client.hpp index 3f254c6..70b64ac 100644 --- a/src/filter_z3950_client.hpp +++ b/src/filter_z3950_client.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_z3950_client.hpp,v 1.6 2006-01-04 11:19:04 adam Exp $ +/* $Id: filter_z3950_client.hpp,v 1.7 2006-01-04 11:55:32 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -27,7 +27,7 @@ namespace yp2 { } extern "C" { - extern const struct yp2_filter_struct yp2_filter_z3950_client; + extern struct yp2_filter_struct yp2_filter_z3950_client; } #endif diff --git a/src/test_filter_factory.cpp b/src/test_filter_factory.cpp index fb28d36..4ee6960 100644 --- a/src/test_filter_factory.cpp +++ b/src/test_filter_factory.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter_factory.cpp,v 1.8 2005-12-11 17:25:59 adam Exp $ +/* $Id: test_filter_factory.cpp,v 1.9 2006-01-04 11:55:32 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -96,8 +96,12 @@ BOOST_AUTO_UNIT_TEST( test_filter_factory_2 ) const std::string id = "dl"; + // first load BOOST_CHECK(ffactory.add_creator_dyn(id, ".libs")); - + + // test double load + BOOST_CHECK(ffactory.add_creator_dyn(id, ".libs")); + yp2::filter::Base* filter = 0; filter = ffactory.create(id); diff --git a/src/test_router_flexml.cpp b/src/test_router_flexml.cpp index e6ee8fc..8cfbf87 100644 --- a/src/test_router_flexml.cpp +++ b/src/test_router_flexml.cpp @@ -1,4 +1,4 @@ -/* $Id: test_router_flexml.cpp,v 1.8 2006-01-04 11:19:04 adam Exp $ +/* $Id: test_router_flexml.cpp,v 1.9 2006-01-04 11:55:32 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -34,8 +34,11 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_1 ) " \n" " 210\n" " \n" - " \n" - " mylog.log\n" + " \n" + " mylog1.log\n" + " \n" + " \n" + " mylog2.log\n" " \n" " \n" " \n" -- 1.7.10.4