]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Use RegisteredRunners to initialize/clean the ESI module (#965)
authorAmos Jeffries <yadij@users.noreply.github.com>
Thu, 3 Feb 2022 03:09:07 +0000 (03:09 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 3 Feb 2022 07:01:35 +0000 (07:01 +0000)
src/esi/ExpatParser.cc
src/esi/Libxml2Parser.cc
src/esi/Makefile.am
src/esi/Module.cc [deleted file]
src/esi/Module.h [deleted file]
src/main.cc

index a57c7ee9da6b25668261cf61a2c9dfae23323445..9826d5c5b9fda2d13c498874dd5373de6208afab 100644 (file)
 
 #if USE_SQUID_ESI && HAVE_LIBEXPAT
 
+#include "base/RunnersRegistry.h"
 #include "esi/ExpatParser.h"
 
+#include <memory>
+
+namespace Esi
+{
+
+class ExpatRr : public RegisteredRunner
+{
+public:
+    void finalizeConfig()
+    {
+        registration.reset(new ESIParser::Register("expat", &ESIExpatParser::NewParser));
+    }
+
+private:
+    std::unique_ptr<ESIParser::Register> registration;
+};
+
+RunnerRegistrationEntry(ExpatRr);
+
+}
+
 EsiParserDefinition(ESIExpatParser);
 
 ESIExpatParser::ESIExpatParser(ESIParserClient *aClient) : theClient (aClient)
index 6c14c8c3a05bbc68a8c522d4ea800842b2b6c0c4..9a42144f4d9b92515705a6baf4b19f8cc87dcdb7 100644 (file)
 
 #if USE_SQUID_ESI && HAVE_LIBXML2
 
+#include "base/RunnersRegistry.h"
 #include "esi/Libxml2Parser.h"
 
+#include <memory>
+
+namespace Esi
+{
+
+class Libxml2Rr : public RegisteredRunner
+{
+public:
+    void finalizeConfig()
+    {
+        registration.reset(new ESIParser::Register("libxml2", &ESILibxml2Parser::NewParser));
+    }
+
+private:
+    std::unique_ptr<ESIParser::Register> registration;
+};
+
+RunnerRegistrationEntry(Libxml2Rr);
+
+}
+
 // the global document that will store the resolved entity
 // definitions
 static htmlDocPtr entity_doc = NULL;
index eba97714fdefdd1902f4050cf920db179931b847..eb6ecd17986e5fb619077abc340f0e0894a92e99 100644 (file)
@@ -40,8 +40,6 @@ libesi_la_SOURCES = \
        Include.cc \
        Include.h \
        Literal.h \
-       Module.cc \
-       Module.h \
        Parser.cc \
        Parser.h \
        Segment.cc \
diff --git a/src/esi/Module.cc b/src/esi/Module.cc
deleted file mode 100644 (file)
index f5eeb4f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#include "squid.h"
-#include "esi/Libxml2Parser.h"
-#include "esi/Module.h"
-/* include for esi/ExpatParser.h must follow esi/Libxml2Parser.h */
-/* do not remove this comment, as it acts as barrier for the autmatic sorting */
-#include "esi/ExpatParser.h"
-
-#if HAVE_LIBXML2
-static ESIParser::Register *prLibxml = 0;
-#endif
-#if HAVE_LIBEXPAT
-static ESIParser::Register *prExpat = 0;
-#endif
-
-void Esi::Init()
-{
-#if HAVE_LIBEXPAT
-    assert(!prExpat); // we should be called once
-    prExpat = new ESIParser::Register("expat", &ESIExpatParser::NewParser);
-#endif
-
-#if HAVE_LIBXML2
-    assert(!prLibxml); // we should be called once
-    prLibxml = new ESIParser::Register("libxml2", &ESILibxml2Parser::NewParser);
-#endif
-}
-
-void Esi::Clean()
-{
-#if HAVE_LIBEXPAT
-    delete prExpat;
-    prExpat = NULL;
-#endif
-
-#if HAVE_LIBXML2
-    delete prLibxml;
-    prLibxml = NULL;
-#endif
-}
-
diff --git a/src/esi/Module.h b/src/esi/Module.h
deleted file mode 100644 (file)
index 4d61cc2..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#ifndef SQUID_ESI_MODULE_H
-#define SQUID_ESI_MODULE_H
-
-namespace Esi
-{
-
-void Init();
-void Clean();
-
-} // namespace Esi
-
-#endif /* SQUID_ESI_MODULE_H */
-
index cceb2b40d914c6d2113fb05da5fceb35b805157d..fd995d543e0b5fc91060bc13734db9eac16ee0c1 100644 (file)
 #if USE_ADAPTATION
 #include "adaptation/Config.h"
 #endif
-#if USE_SQUID_ESI
-#include "esi/Module.h"
-#endif
 #if SQUID_SNMP
 #include "snmp_core.h"
 #endif
@@ -1313,10 +1310,6 @@ mainInitialize(void)
     Adaptation::Config::Finalize(enableAdaptation);
 #endif
 
-#if USE_SQUID_ESI
-    Esi::Init();
-#endif
-
 #if USE_DELAY_POOLS
     Config.ClientDelay.finalize();
 #endif
@@ -2094,10 +2087,6 @@ SquidShutdown()
     releaseServerSockets();
     commCloseAllSockets();
 
-#if USE_SQUID_ESI
-    Esi::Clean();
-#endif
-
 #if USE_DELAY_POOLS
     DelayPools::FreePools();
 #endif