Make public yp2_filter_struct non-const. If not, the linker symbol
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 4 Jan 2006 11:55:31 +0000 (11:55 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 4 Jan 2006 11:55:31 +0000 (11:55 +0000)
is screwed. Test for double dl-load in FilterFactory.

19 files changed:
src/factory_static.cpp
src/filter_backend_test.cpp
src/filter_backend_test.hpp
src/filter_dl.cpp
src/filter_factory.cpp
src/filter_frontend_net.cpp
src/filter_frontend_net.hpp
src/filter_log.cpp
src/filter_log.hpp
src/filter_session_shared.cpp
src/filter_session_shared.hpp
src/filter_template.cpp
src/filter_template.hpp
src/filter_virt_db.cpp
src/filter_virt_db.hpp
src/filter_z3950_client.cpp
src/filter_z3950_client.hpp
src/test_filter_factory.cpp
src/test_router_flexml.cpp

index ff70983..1f684f6 100644 (file)
@@ -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,
index d622530..144556e 100644 (file)
@@ -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
index 66dcc5d..7c2b71e 100644 (file)
@@ -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
index 04a088e..54c1051 100644 (file)
@@ -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
index a5406bd..6efdc89 100644 (file)
@@ -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<std::string, CreateFilterCallback> CallbackMap;
+        typedef std::map<std::string, CreateFilterCallback>::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)
index 8aa35a2..bf26441 100644 (file)
@@ -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
index 0f6abe9..f90d69b 100644 (file)
@@ -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
index 4142be7..86ee793 100644 (file)
@@ -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
index a829d80..2ae395a 100644 (file)
@@ -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
index 0936bc0..7a8b4fa 100644 (file)
@@ -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
index c584467..ff8898d 100644 (file)
@@ -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
index 07c0d2a..2aced06 100644 (file)
@@ -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
index f6b2e38..0b437cb 100644 (file)
@@ -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
index 3ba8487..b4427b2 100644 (file)
@@ -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
index 9e2991e..d5065b5 100644 (file)
@@ -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
index d98a5b7..178a3b8 100644 (file)
@@ -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
index 3f254c6..70b64ac 100644 (file)
@@ -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
index fb28d36..4ee6960 100644 (file)
@@ -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);
 
index e6ee8fc..8cfbf87 100644 (file)
@@ -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 )
             "    <filter id=\"front_default\" type=\"frontend_net\">\n"
             "      <port>210</port>\n"
             "    </filter>\n"
-            "    <filter id=\"log_cout\" type=\"log\">\n"
-            "      <logfile>mylog.log</logfile>\n"
+            "    <filter id=\"log_cout1\" type=\"log\">\n"
+            "      <logfile>mylog1.log</logfile>\n"
+            "    </filter>\n"
+            "    <filter id=\"log_cout2\" type=\"log\">\n"
+            "      <logfile>mylog2.log</logfile>\n"
             "    </filter>\n"
             "  </filters>\n"
             "  <routes>\n"