|
|
|
@ -36,9 +36,7 @@
|
|
|
|
#include <signal.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
|
|
#include <glob.h>
|
|
|
|
#include <QDir>
|
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Daemon * Daemon::m_instance = NULL;
|
|
|
|
Daemon * Daemon::m_instance = NULL;
|
|
|
|
int Daemon::m_lockFd = -1;
|
|
|
|
int Daemon::m_lockFd = -1;
|
|
|
|
@ -274,38 +272,50 @@ void Daemon::loadSingleInstancePlugin()
|
|
|
|
|
|
|
|
|
|
|
|
void Daemon::loadBoosterPlugins()
|
|
|
|
void Daemon::loadBoosterPlugins()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString strPluginDir(BOOSTER_PLUGIN_DIR);
|
|
|
|
const char* PATTERN = "lib*booster.so";
|
|
|
|
QDir pluginDir(strPluginDir);
|
|
|
|
const int BUF_LEN = 256;
|
|
|
|
|
|
|
|
|
|
|
|
QStringList filters;
|
|
|
|
|
|
|
|
filters << "lib*booster.so";
|
|
|
|
|
|
|
|
pluginDir.setNameFilters(filters);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Loop through entries in the plugin dir
|
|
|
|
if (strlen(PATTERN) + strlen(BOOSTER_PLUGIN_DIR) + 2 > BUF_LEN)
|
|
|
|
QStringListIterator entry(pluginDir.entryList());
|
|
|
|
|
|
|
|
while (entry.hasNext())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString file = entry.next();
|
|
|
|
Logger::logError("Daemon: path to plugins too long");
|
|
|
|
QString path = strPluginDir + QDir::separator() + file;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char * constPath = path.toAscii().constData();
|
|
|
|
char buffer[BUF_LEN];
|
|
|
|
void * handle = dlopen(constPath, RTLD_NOW | RTLD_GLOBAL);
|
|
|
|
memset(buffer, 0, BUF_LEN);
|
|
|
|
if (!handle)
|
|
|
|
strcpy(buffer, BOOSTER_PLUGIN_DIR);
|
|
|
|
{
|
|
|
|
strcat(buffer, "/");
|
|
|
|
Logger::logWarning("Daemon: dlopening booster failed: %s", dlerror());
|
|
|
|
strcat(buffer, PATTERN);
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
// get full path to all plugins
|
|
|
|
|
|
|
|
glob_t globbuf;
|
|
|
|
|
|
|
|
if (glob(buffer, 0, NULL, &globbuf) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (__size_t i = 0; i < globbuf.gl_pathc; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char newType = BoosterPluginRegistry::validateAndRegisterPlugin(handle);
|
|
|
|
void *handle = dlopen(globbuf.gl_pathv[i], RTLD_NOW | RTLD_GLOBAL);
|
|
|
|
if (newType)
|
|
|
|
if (!handle)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger::logInfo("Daemon: Booster of type '%c' loaded.'", newType);
|
|
|
|
Logger::logWarning("Daemon: dlopening booster failed: %s", dlerror());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger::logWarning("Daemon: Invalid booster plugin: '%s'", constPath);
|
|
|
|
char newType = BoosterPluginRegistry::validateAndRegisterPlugin(handle);
|
|
|
|
|
|
|
|
if (newType)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger::logInfo("Daemon: Booster of type '%c' loaded.'", newType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger::logWarning("Daemon: Invalid booster plugin: '%s'", buffer);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger::logError("Daemon: can't find booster plugins");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|