no behaviour changes.
// 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();
void *
LoadableModule::openModule()
{
- return lt_dlopen(theName.termedBuf());
+ return lt_dlopen(theName.c_str());
}
bool
#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();
#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 << "'");
}
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());
}
#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 */
CpuAffinityMap *cpuAffinityMap;
#if USE_LOADABLE_MODULES
- wordlist *loadable_module_names;
+ SBufList loadable_module_names;
#endif
int client_ip_max_connections;
DOC_END
NAME: loadable_modules
-TYPE: wordlist
+TYPE: SBufList
IFDEF: USE_LOADABLE_MODULES
LOC: Config.loadable_module_names
DEFAULT: none