Skip to content

Commit

Permalink
daemons: delete unused function arguments used for old plugin_* direc…
Browse files Browse the repository at this point in the history
…tives
  • Loading branch information
jengelh committed Jul 25, 2022
1 parent b019bc4 commit b8146cd
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 58 deletions.
10 changes: 3 additions & 7 deletions exch/http/hpm_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,15 @@ struct HPM_CONTEXT {
static int g_context_num;
static uint64_t g_max_size;
static uint64_t g_cache_size;
static char g_plugins_path[256];
static HPM_PLUGIN *g_cur_plugin;
static std::list<HPM_PLUGIN> g_plugin_list;
static HPM_CONTEXT *g_context_list;
static std::vector<std::string> g_plugin_names;

void hpm_processor_init(int context_num, const char *plugins_path,
std::vector<std::string> &&names, uint64_t cache_size, uint64_t max_size,
bool ignerr)
void hpm_processor_init(int context_num, std::vector<std::string> &&names,
uint64_t cache_size, uint64_t max_size)
{
g_context_num = context_num;
gx_strlcpy(g_plugins_path, plugins_path, GX_ARRAY_SIZE(g_plugins_path));
g_plugin_names = std::move(names);
g_cache_size = cache_size;
g_max_size = max_size;
Expand Down Expand Up @@ -324,7 +321,7 @@ static int hpm_processor_load_library(const char *plugin_name)

plug.handle = dlopen(plugin_name, RTLD_LAZY);
if (plug.handle == nullptr && strchr(plugin_name, '/') == nullptr)
plug.handle = dlopen((g_plugins_path + "/"s + plugin_name).c_str(), RTLD_LAZY);
plug.handle = dlopen((PKGLIBDIR + "/"s + plugin_name).c_str(), RTLD_LAZY);
if (plug.handle == nullptr) {
printf("[hpm_processor]: error loading %s: %s\n", fake_path, dlerror());
printf("[hpm_processor]: the plugin %s is not loaded\n", fake_path);
Expand Down Expand Up @@ -380,7 +377,6 @@ void hpm_processor_stop()
free(g_context_list);
g_context_list = NULL;
}
g_plugins_path[0] = '\0';
}

BOOL hpm_processor_get_context(HTTP_CONTEXT *phttp)
Expand Down
2 changes: 1 addition & 1 deletion exch/http/hpm_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct HPM_PLUGIN {
bool completed_init = false;
};

extern void hpm_processor_init(int context_num, const char *plugins_path, std::vector<std::string> &&names, uint64_t cache_size, uint64_t max_size, bool ignerr);
extern void hpm_processor_init(int context_num, std::vector<std::string> &&names, uint64_t cache_size, uint64_t max_size);
extern int hpm_processor_run();
extern void hpm_processor_stop();
BOOL hpm_processor_get_context(HTTP_CONTEXT *phttp);
Expand Down
14 changes: 5 additions & 9 deletions exch/http/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,10 @@ int main(int argc, const char **argv) try
else
printf("[system]: set file limitation to %zu\n", static_cast<size_t>(rl.rlim_cur));
}
service_init({PKGLIBDIR,
g_config_file->get_value("config_file_path"),
service_init({g_config_file->get_value("config_file_path"),
g_config_file->get_value("data_file_path"),
g_config_file->get_value("state_path"),
std::move(g_dfl_svc_plugins),
false,
context_num, "http"});
std::move(g_dfl_svc_plugins), context_num, "http"});
auto cleanup_6 = make_scope_exit(service_stop);
if (!service_register_service("ndr_stack_alloc",
reinterpret_cast<void *>(pdu_processor_ndr_stack_alloc),
Expand Down Expand Up @@ -340,7 +337,7 @@ int main(int argc, const char **argv) try
"http.cfg:context_num,context_average_mem");
pdu_processor_init(context_num, netbios_name,
dns_name, dns_domain, TRUE, max_request_mem,
PKGLIBDIR, std::move(g_dfl_proc_plugins), false);
std::move(g_dfl_proc_plugins));
auto cleanup_12 = make_scope_exit(pdu_processor_stop);
printf("---------------------------- proc plugins begin "
"----------------------------\n");
Expand All @@ -354,9 +351,8 @@ int main(int argc, const char **argv) try
"-----------------------------\n");
}

hpm_processor_init(context_num, PKGLIBDIR,
std::move(g_dfl_hpm_plugins), hpm_cache_size, hpm_max_size,
false);
hpm_processor_init(context_num, std::move(g_dfl_hpm_plugins),
hpm_cache_size, hpm_max_size);
auto cleanup_14 = make_scope_exit(hpm_processor_stop);
printf("---------------------------- hpm plugins begin "
"----------------------------\n");
Expand Down
8 changes: 2 additions & 6 deletions exch/http/pdu_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ static BOOL g_header_signing;
static int g_connection_ratio;
static char g_dns_domain[128];
static char g_netbios_name[128];
static char g_plugins_path[256];
static size_t g_max_request_mem;
static uint32_t g_last_async_id;
static thread_local DCERPC_CALL *g_call_key;
Expand Down Expand Up @@ -197,8 +196,7 @@ static size_t pdu_processor_ndr_stack_size(NDR_STACK_ROOT *pstack_root, int type

void pdu_processor_init(int connection_num, const char *netbios_name,
const char *dns_name, const char *dns_domain, BOOL header_signing,
size_t max_request_mem, const char *plugins_path,
std::vector<std::string> &&names, bool ignerr)
size_t max_request_mem, std::vector<std::string> &&names)
{
static constexpr unsigned int connection_ratio = 10;
union {
Expand All @@ -220,7 +218,6 @@ void pdu_processor_init(int connection_num, const char *netbios_name,
gx_strlcpy(g_dns_name, dns_name, GX_ARRAY_SIZE(g_dns_name));
gx_strlcpy(g_dns_domain, dns_domain, GX_ARRAY_SIZE(g_dns_domain));
g_header_signing = header_signing;
gx_strlcpy(g_plugins_path, plugins_path, GX_ARRAY_SIZE(g_plugins_path));
g_plugin_names = std::move(names);
}

Expand Down Expand Up @@ -309,7 +306,6 @@ void pdu_processor_stop()
g_plugin_list.clear();
g_endpoint_list.clear();
g_async_hash.reset();
g_plugins_path[0] = '\0';
}

static uint16_t pdu_processor_find_secondary(const char *host,
Expand Down Expand Up @@ -3473,7 +3469,7 @@ static int pdu_processor_load_library(const char* plugin_name)

plug.handle = dlopen(plugin_name, RTLD_LAZY);
if (plug.handle == nullptr && strchr(plugin_name, '/') == nullptr)
plug.handle = dlopen((g_plugins_path + "/"s + plugin_name).c_str(), RTLD_LAZY);
plug.handle = dlopen((PKGLIBDIR + "/"s + plugin_name).c_str(), RTLD_LAZY);
if (plug.handle == nullptr) {
printf("[pdu_processor]: error loading %s: %s\n", fake_path,
dlerror());
Expand Down
2 changes: 1 addition & 1 deletion exch/http/pdu_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct BLOB_NODE {
DATA_BLOB blob;
};

extern void pdu_processor_init(int connection_num, const char *netbios_name, const char *dns_name, const char *dns_domain, BOOL header_signing, size_t max_request_mem, const char *plugins_path, std::vector<std::string> &&names, bool ignerr);
extern void pdu_processor_init(int connection_num, const char *netbios_name, const char *dns_name, const char *dns_domain, BOOL header_signing, size_t max_request_mem, std::vector<std::string> &&names);
extern int pdu_processor_run();
extern void pdu_processor_stop();
extern std::unique_ptr<PDU_PROCESSOR> pdu_processor_create(const char *host, uint16_t tcp_port);
Expand Down
5 changes: 2 additions & 3 deletions exch/midb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,10 @@ int main(int argc, const char **argv) try
}

unsigned int cmd_debug = pconfig->get_ll("midb_cmd_debug");
service_init({PKGLIBDIR,
g_config_file->get_value("config_file_path"),
service_init({g_config_file->get_value("config_file_path"),
g_config_file->get_value("data_path"),
g_config_file->get_value("state_path"),
std::move(g_dfl_svc_plugins), false, threads_num});
std::move(g_dfl_svc_plugins), threads_num});
auto cl_0 = make_scope_exit(service_stop);

exmdb_client_init(proxy_num, stub_num);
Expand Down
5 changes: 2 additions & 3 deletions exch/zcore/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,10 @@ int main(int argc, const char **argv) try
unsigned int threads_num = pconfig->get_ll("zarafa_threads_num");
printf("[system]: connection threads number is %d\n", threads_num);

service_init({PKGLIBDIR,
g_config_file->get_value("config_file_path"),
service_init({g_config_file->get_value("config_file_path"),
g_config_file->get_value("data_file_path"),
g_config_file->get_value("state_path"),
std::move(g_dfl_svc_plugins), false, threads_num});
std::move(g_dfl_svc_plugins), threads_num});
auto cl_0 = make_scope_exit(service_stop);

unsigned int table_size = pconfig->get_ll("address_table_size");
Expand Down
4 changes: 1 addition & 3 deletions include/gromox/svc_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
#include <gromox/plugin.hpp>

struct service_init_param {
const char *plugin_dir = nullptr, *config_dir = nullptr;
const char *data_dir = nullptr, *state_dir = nullptr;
const char *config_dir = nullptr, *data_dir = nullptr, *state_dir = nullptr;
std::vector<std::string> plugin_list;
bool plugin_ignloaderr = false;
unsigned int context_num = 0;
const char *prog_id = nullptr;
};
Expand Down
6 changes: 2 additions & 4 deletions lib/svc_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static const char *service_get_data_path();
static unsigned int service_get_context_num();
static const char *service_get_host_ID();

static char g_init_path[256], g_config_dir[256], g_data_dir[256], g_state_dir[256];
static char g_config_dir[256], g_data_dir[256], g_state_dir[256];
static std::list<SVC_PLUG_ENTITY> g_list_plug;
static std::vector<std::shared_ptr<service_entry>> g_list_service;
static SVC_PLUG_ENTITY *g_cur_plug;
Expand All @@ -83,7 +83,6 @@ static const char *service_get_prog_id() { return g_program_identifier; }
void service_init(service_init_param &&parm)
{
g_context_num = parm.context_num;
gx_strlcpy(g_init_path, parm.plugin_dir, sizeof(g_init_path));
gx_strlcpy(g_config_dir, parm.config_dir, sizeof(g_config_dir));
gx_strlcpy(g_data_dir, parm.data_dir, sizeof(g_data_dir));
gx_strlcpy(g_state_dir, parm.state_dir, sizeof(g_state_dir));
Expand Down Expand Up @@ -134,7 +133,6 @@ int service_run()
void service_stop()
{
g_list_plug.clear();
g_init_path[0] = '\0';
}

/*
Expand Down Expand Up @@ -165,7 +163,7 @@ static int service_load_library(const char *path)
SVC_PLUG_ENTITY plug;
plug.handle = dlopen(path, RTLD_LAZY);
if (plug.handle == nullptr && strchr(path, '/') == nullptr)
plug.handle = dlopen((g_init_path + "/"s + path).c_str(), RTLD_LAZY);
plug.handle = dlopen((PKGLIBDIR + "/"s + path).c_str(), RTLD_LAZY);
if (plug.handle == nullptr) {
fprintf(stderr, "[service]: error loading %s: %s\n", fake_path, dlerror());
fprintf(stderr, "[service]: the plugin %s is not loaded\n", fake_path);
Expand Down
6 changes: 2 additions & 4 deletions mda/delivery_app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,10 @@ int main(int argc, const char **argv) try
HX_unit_size(temp_buff, arsizeof(temp_buff), max_mem, 1024, 0);
printf("[message_dequeue]: maximum allocated memory is %s\n", temp_buff);

service_init({PKGLIBDIR,
g_config_file->get_value("config_file_path"),
service_init({g_config_file->get_value("config_file_path"),
g_config_file->get_value("data_file_path"),
g_config_file->get_value("state_path"),
std::move(g_dfl_svc_plugins), false,
threads_max + free_contexts});
std::move(g_dfl_svc_plugins), threads_max + free_contexts});
printf("--------------------------- service plugins begin"
"---------------------------\n");
if (service_run_early() != 0) {
Expand Down
5 changes: 2 additions & 3 deletions mda/smtp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,10 @@ int main(int argc, const char **argv) try
else
printf("[system]: set file limitation to %zu\n", static_cast<size_t>(rl.rlim_cur));
}
service_init({PKGLIBDIR,
g_config_file->get_value("config_file_path"),
service_init({g_config_file->get_value("config_file_path"),
g_config_file->get_value("data_file_path"),
g_config_file->get_value("state_path"),
std::move(g_dfl_svc_plugins), false, scfg.context_num});
std::move(g_dfl_svc_plugins), scfg.context_num});
printf("--------------------------- service plugins begin"
"---------------------------\n");
if (service_run_early() != 0) {
Expand Down
5 changes: 2 additions & 3 deletions mra/imap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,10 @@ int main(int argc, const char **argv) try
else
printf("[system]: set file limitation to %zu\n", static_cast<size_t>(rl.rlim_cur));
}
service_init({PKGLIBDIR,
g_config_file->get_value("config_file_path"),
service_init({g_config_file->get_value("config_file_path"),
g_config_file->get_value("data_file_path"),
g_config_file->get_value("state_path"),
std::move(g_dfl_svc_plugins), false, context_num});
std::move(g_dfl_svc_plugins), context_num});
printf("--------------------------- service plugins begin"
"---------------------------\n");
if (service_run_early() != 0) {
Expand Down
5 changes: 2 additions & 3 deletions mra/pop3/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,10 @@ int main(int argc, const char **argv) try
else
printf("[system]: set file limitation to %zu\n", static_cast<size_t>(rl.rlim_cur));
}
service_init({PKGLIBDIR,
g_config_file->get_value("config_file_path"),
service_init({g_config_file->get_value("config_file_path"),
g_config_file->get_value("data_file_path"),
g_config_file->get_value("state_path"),
std::move(g_dfl_svc_plugins), false, context_num});
std::move(g_dfl_svc_plugins), context_num});
printf("--------------------------- service plugins begin"
"---------------------------\n");
if (service_run_early() != 0) {
Expand Down
5 changes: 2 additions & 3 deletions tools/eml2mt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,10 @@ int main(int argc, const char **argv) try
fprintf(stderr, "Something went wrong with config files\n");
return EXIT_FAILURE;
}
service_init({PKGLIBDIR,
g_config_file->get_value("config_file_path"),
service_init({g_config_file->get_value("config_file_path"),
g_config_file->get_value("data_path"),
g_config_file->get_value("state_path"),
std::move(g_svc_plugins), false, 1});
std::move(g_svc_plugins), 1});
auto cl_0 = make_scope_exit(service_stop);
if (service_run_early() != 0 || service_run() != 0) {
fprintf(stderr, "service_run: failed\n");
Expand Down
5 changes: 2 additions & 3 deletions tools/exm2eml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,10 @@ int main(int argc, const char **argv) try
fprintf(stderr, "Something went wrong with config files\n");
return EXIT_FAILURE;
}
service_init({PKGLIBDIR,
g_config_file->get_value("config_file_path"),
service_init({g_config_file->get_value("config_file_path"),
g_config_file->get_value("data_path"),
g_config_file->get_value("state_path"),
std::move(g_svc_plugins), false, 1});
std::move(g_svc_plugins), 1});
auto cl_0 = make_scope_exit(service_stop);
if (service_run_early() != 0 || service_run() != 0) {
fprintf(stderr, "service_run: failed\n");
Expand Down
3 changes: 1 addition & 2 deletions tools/pam_gromox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ PAM_EXTERN GX_EXPORT int pam_sm_authenticate(pam_handle_t *pamh, int flags,
config_dir = PKGSYSCONFDIR "/pam:" PKGSYSCONFDIR;

std::lock_guard<std::mutex> holder(g_svc_once);
service_init({PKGLIBDIR, config_dir, "", "",
std::move(g_dfl_svc_plugins), false, 1});
service_init({config_dir, "", "", std::move(g_dfl_svc_plugins), 1});
if (service_run_early() != 0)
return PAM_AUTH_ERR;
if (service_run() != 0)
Expand Down

0 comments on commit b8146cd

Please sign in to comment.