Reload modules by path

This commit is contained in:
Ed Kellett 2020-06-02 16:17:26 +01:00
parent c7561f03ef
commit df7e3dabce
No known key found for this signature in database
GPG key ID: CB9986DEF342FABC
2 changed files with 8 additions and 1 deletions

View file

@ -45,6 +45,7 @@ struct module
lt_dlhandle address; lt_dlhandle address;
int core; /* This is int for backwards compat reasons */ int core; /* This is int for backwards compat reasons */
int origin; /* Ditto */ int origin; /* Ditto */
char *path;
int mapi_version; int mapi_version;
void *mapi_header; /* actually struct mapi_mheader_av<mapi_version> */ void *mapi_header; /* actually struct mapi_mheader_av<mapi_version> */
rb_dlink_node node; rb_dlink_node node;

View file

@ -424,6 +424,7 @@ unload_one_module(const char *name, bool warn)
rb_dlinkDelete(&mod->node, &module_list); rb_dlinkDelete(&mod->node, &module_list);
rb_free(mod->name); rb_free(mod->name);
rb_free(mod->path);
rb_free(mod); rb_free(mod);
if(warn) if(warn)
@ -653,6 +654,7 @@ load_a_module(const char *path, bool warn, int origin, bool core)
mod->mapi_header = mapi_version; mod->mapi_header = mapi_version;
mod->mapi_version = MAPI_VERSION(*mapi_version); mod->mapi_version = MAPI_VERSION(*mapi_version);
mod->origin = origin; mod->origin = origin;
mod->path = rb_strdup(path);
rb_dlinkAdd(mod, &mod->node, &module_list); rb_dlinkAdd(mod, &mod->node, &module_list);
if(warn) if(warn)
@ -691,6 +693,7 @@ modules_do_reload(void *info_)
int check_core; int check_core;
int origin; int origin;
char *m_bn = rb_basename(info->module); char *m_bn = rb_basename(info->module);
char *path;
struct Client *source_p = find_id(info->id); struct Client *source_p = find_id(info->id);
if((mod = findmodule_byname(m_bn)) == NULL) if((mod = findmodule_byname(m_bn)) == NULL)
@ -703,6 +706,7 @@ modules_do_reload(void *info_)
origin = mod->origin; origin = mod->origin;
check_core = mod->core; check_core = mod->core;
path = rb_strdup(mod->path);
mod_remember_clicaps(); mod_remember_clicaps();
@ -711,10 +715,11 @@ modules_do_reload(void *info_)
if (source_p) sendto_one_notice(source_p, ":Module %s is not loaded", m_bn); if (source_p) sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
rb_free(info); rb_free(info);
rb_free(m_bn); rb_free(m_bn);
rb_free(path);
return; return;
} }
if((load_one_module(m_bn, origin, check_core) == false) && check_core) if((load_a_module(path, true, origin, check_core) == false) && check_core)
{ {
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"Error reloading core module: %s: terminating ircd", m_bn); "Error reloading core module: %s: terminating ircd", m_bn);
@ -726,6 +731,7 @@ modules_do_reload(void *info_)
rb_free(info); rb_free(info);
rb_free(m_bn); rb_free(m_bn);
rb_free(path);
} }
void void