]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Convert loadable_modules to SBufList (#1738)
authorAmos Jeffries <yadij@users.noreply.github.com>
Fri, 15 Mar 2024 17:26:29 +0000 (17:26 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 16 Mar 2024 07:33:28 +0000 (07:33 +0000)
no behaviour changes.

src/LoadableModule.cc
src/LoadableModule.h
src/LoadableModules.cc
src/LoadableModules.h
src/SquidConfig.h
src/cf.data.pre

index efaf8efcffb28d6fb8e9f94e3ab6a2e519ce0e5e..0291c0978c07bde4881331228b727a6a183cc199 100644 (file)
@@ -14,7 +14,8 @@
 // Note: We must use preprocessor instead of C ifs because if dlopen()
 // is seen by the static linker, the linker will complain.
 
-LoadableModule::LoadableModule(const String &aName): theName(aName), theHandle(nullptr)
+LoadableModule::LoadableModule(const SBuf &aName):
+    theName(aName)
 {
     // Initialise preloaded symbol lookup table.
     LTDL_SET_PRELOADED_SYMBOLS();
@@ -62,7 +63,7 @@ LoadableModule::unload()
 void *
 LoadableModule::openModule()
 {
-    return lt_dlopen(theName.termedBuf());
+    return lt_dlopen(theName.c_str());
 }
 
 bool
index 3c246758153adf9bb7c47c850f9a73c195333642..8601b4984eb125af566797dcdcd7fbdf2a642221 100644 (file)
@@ -9,26 +9,26 @@
 #ifndef SQUID_SRC_LOADABLEMODULE_H
 #define SQUID_SRC_LOADABLEMODULE_H
 
-#include "SquidString.h"
+#include "sbuf/SBuf.h"
 
 // wrapper for dlopen(3), libltdl, and friends
 class LoadableModule
 {
 public:
-    LoadableModule(const String &aName);
+    explicit LoadableModule(const SBuf &aName);
     ~LoadableModule();           // unloads if loaded
 
     bool loaded() const;
-    const String &name() const { return theName; }
-    const String &error() const { return theError; }
+    const auto &name() const { return theName; }
+    const auto &error() const { return theError; }
 
     void load(); // throws Texc
     void unload(); // throws Texc
 
 protected:
-    String theName;
-    String theError;
-    void *theHandle;
+    SBuf theName;
+    SBuf theError;
+    void *theHandle = nullptr;
 
 private:
     void *openModule();
index d3024d2b375d05b3b448057c4cf218ea7e8b9409..1a5258e372737fdeb116be2b9ecaf20121501ddf 100644 (file)
@@ -8,17 +8,16 @@
 
 #include "squid.h"
 #include "debug/Messages.h"
-#include "debug/Stream.h"
 #include "LoadableModule.h"
 #include "LoadableModules.h"
-#include "wordlist.h"
+#include "sbuf/List.h"
 
 static void
-LoadModule(const char *fname)
+LoadModule(const SBuf &fname)
 {
     debugs(1, DBG_IMPORTANT, "Loading Squid module from '" << fname << "'");
 
-    LoadableModule *m = new LoadableModule(fname);
+    const auto m = new LoadableModule(fname);
     m->load();
     debugs(1, 2, "Loaded Squid module from '" << fname << "'");
 
@@ -26,11 +25,11 @@ LoadModule(const char *fname)
 }
 
 void
-LoadableModulesConfigure(const wordlist *names)
+LoadableModulesConfigure(const SBufList &names)
 {
-    int count = 0;
-    for (const wordlist *i = names; i; i = i->next, ++count)
-        LoadModule(i->key);
-    debugs(1, Important(25), "Squid plugin modules loaded: " << count);
+    for (const auto &name : names) {
+        LoadModule(name);
+    }
+    debugs(1, Important(25), "Squid plugin modules loaded: " << names.size());
 }
 
index 25e1624b4d5f6bf18327a4ff7fa1136f8c43e0ff..8cb7ef8028a531d0b2ce5b561a800789f6305d09 100644 (file)
@@ -9,11 +9,13 @@
 #ifndef SQUID_SRC_LOADABLEMODULES_H
 #define SQUID_SRC_LOADABLEMODULES_H
 
+#include "sbuf/forward.h"
+
 // TODO: add reporting for cachemgr
 // TODO: add reconfiguration support
 
-class wordlist;
-void LoadableModulesConfigure(const wordlist *names);
+/// dynamically load named libraries, in the listed order
+void LoadableModulesConfigure(const SBufList &);
 
 #endif /* SQUID_SRC_LOADABLEMODULES_H */
 
index 83063220ade36d4101ed8570743fc676bc3c4eb7..8ac9a47b94112d43ecb74616537b6cb0968c1131 100644 (file)
@@ -519,7 +519,7 @@ public:
     CpuAffinityMap *cpuAffinityMap;
 
 #if USE_LOADABLE_MODULES
-    wordlist *loadable_module_names;
+    SBufList loadable_module_names;
 #endif
 
     int client_ip_max_connections;
index 644899e67698240866c086da8e7399f11fd8da1e..48e40882ab11b585813298e92d761afcce65dc1e 100644 (file)
@@ -9766,7 +9766,7 @@ ecap_service s2 respmod_precache ecap://filters.R.us/virusFilter config=/etc/vf.
 DOC_END
 
 NAME: loadable_modules
-TYPE: wordlist
+TYPE: SBufList
 IFDEF: USE_LOADABLE_MODULES
 LOC: Config.loadable_module_names
 DEFAULT: none