summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--include/modules.h15
-rw-r--r--src/core/os_modload.c32
-rw-r--r--src/core/os_modunload.c38
-rw-r--r--src/modules.c104
-rw-r--r--src/process.c3
6 files changed, 53 insertions, 141 deletions
diff --git a/TODO b/TODO
index de3bd76b2..7b266b0fb 100644
--- a/TODO
+++ b/TODO
@@ -15,6 +15,7 @@ Legend:
[ ] Remove duplicate module creation.. have loadModule return a pointer rather than creating one
[ ] Remove buffered loading/unloading, this makes os_modunload perm, but who cares
[ ] Remove 'delayed' loading, this is necessary because of before/after connected to ircd (ircd is before, rest after), I'm sure this can be done better.
+ [ ] mod_current_buffer needs to go away and be replaced by a proper parser. Commands should then indicate how they want the buffer split.
[+] remove old config, replace with insp-inspired (albeit bind format) config (CBX)
[ ] burn automake with fire (1.9.1?)
[x] SendClientIntroduction should take a UID param, rather than generating one(?)
@@ -74,3 +75,4 @@ Future
[?] Mail memos? think on consequences of this
[ ] Useful/common "third party" modules to core distro
[ ] NS AJOIN
+
diff --git a/include/modules.h b/include/modules.h
index c85e37d21..2fe37f9c2 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -107,7 +107,6 @@ typedef struct Command_ Command;
typedef struct CommandHash_ CommandHash;
typedef struct ModuleLang_ ModuleLang;
typedef struct ModuleHash_ ModuleHash;
-typedef struct ModuleQueue_ ModuleQueue;
typedef struct Message_ Message;
typedef struct MessageHash_ MessageHash;
typedef struct ModuleCallBack_ ModuleCallBack;
@@ -173,14 +172,6 @@ struct ModuleHash_ {
ModuleHash *next;
};
-struct ModuleQueue_ {
- Module *m;
- ModuleOperation op;
- User *u;
-
- ModuleQueue *next;
-};
-
struct Command_ {
char *name;
int (*routine)(User *u);
@@ -373,12 +364,6 @@ int moduleDataDebug(ModuleData **md); /* Allow for debug output of a moduleD
MDE bool moduleMinVersion(int major,int minor,int patch,int build); /* Checks if the current version of anope is before or after a given verison */
/*************************************************************************/
-/* Module Queue Operations */
-MDE int queueModuleLoad(char *name, User *u);
-MDE int queueModuleUnload(char *name, User *u);
-MDE void handleModuleOperationQueue(void);
-
-/*************************************************************************/
/* Some IRCD protocol module support functions */
/** Update the protect deatials, could be either protect or admin etc.. */
diff --git a/src/core/os_modload.c b/src/core/os_modload.c
index 5e7aaebb1..4d876272f 100644
--- a/src/core/os_modload.c
+++ b/src/core/os_modload.c
@@ -55,15 +55,31 @@ void myOperServHelp(User * u)
**/
int do_modload(User * u)
{
- char *name;
+ char *name;
- name = strtok(NULL, "");
- if (!name) {
- syntax_error(s_OperServ, u, "MODLOAD", OPER_MODULE_LOAD_SYNTAX);
- return MOD_CONT;
- }
- if (!queueModuleLoad(name, u))
- notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, name);
+ name = strtok(NULL, "");
+ if (!name)
+ {
+ syntax_error(s_OperServ, u, "MODLOAD", OPER_MODULE_LOAD_SYNTAX);
+ return MOD_CONT;
+ }
+
+ Module *m = findModule(name);
+ if (m)
+ {
+ notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, name);
+ return MOD_CONT;
+ }
+
+ m = createModule(name);
+ alog("Trying to load module [%s]", mod_operation_queue->m->name);
+ status = loadModule(mod_operation_queue->m, mod_operation_queue->u);
+ alog("Module loading status: %d (%s)", status, ModuleGetErrStr(status));
+ if (status != MOD_ERR_OK)
+ {
+ notice_lang(s_OperServ, user, OPER_MODULE_LOAD_FAIL, m->name);
+ destroyModule(m);
+ }
return MOD_CONT;
}
diff --git a/src/core/os_modunload.c b/src/core/os_modunload.c
index 786e5914b..9adfbfd8d 100644
--- a/src/core/os_modunload.c
+++ b/src/core/os_modunload.c
@@ -54,20 +54,36 @@ void myOperServHelp(User * u)
* @param u The user who issued the command
* @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
**/
-int do_modunload(User * u)
+int do_modunload(User *u)
{
- char *name;
+ char *name;
+ int status;
- name = strtok(NULL, "");
- if (!name) {
- syntax_error(s_OperServ, u, "MODUNLOAD",
- OPER_MODULE_UNLOAD_SYNTAX);
- return MOD_CONT;
- }
- if (!queueModuleUnload(name, u))
- notice_lang(s_OperServ, u, OPER_MODULE_REMOVE_FAIL, name);
+ name = strtok(NULL, "");
+ if (!name)
+ {
+ syntax_error(s_OperServ, u, "MODUNLOAD", OPER_MODULE_UNLOAD_SYNTAX);
+ return MOD_CONT;
+ }
+
+ Module *m = findModule(name);
+ if (!m)
+ {
+ syntax_error(s_OperServ, u, "MODUNLOAD", OPER_MODULE_UNLOAD_SYNTAX);
+ return MOD_CONT;
+ }
+
+ alog("Trying to unload module [%s]", m->name);
+
+ status = unloadModule(m, u);
+
+ if (!status)
+ {
+ alog("Module unloading status: %d (%s)", status, ModuleGetErrStr(status));
+ notice_lang(s_OperServ, u, OPER_MODULE_REMOVE_FAIL, name);
+ }
- return MOD_CONT;
+ return MOD_CONT;
}
MODULE_INIT(OSModUnLoad)
diff --git a/src/modules.c b/src/modules.c
index e574e7f68..4d295212d 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -53,7 +53,6 @@ char *mod_current_module_name = NULL;
char *mod_current_buffer = NULL;
User *mod_current_user;
ModuleCallBack *moduleCallBackHead = NULL;
-ModuleQueue *mod_operation_queue = NULL;
int displayCommand(Command * c);
int displayCommandFromHash(CommandHash * cmdTable[], char *name);
@@ -2661,109 +2660,6 @@ void moduleDeleteLanguage(int langNumber)
mod_current_module->lang[langNumber].argc = 0;
}
-/**
- * Enqueue a module operation (load/unload/reload)
- * @param m Module to perform the operation on
- * @param op Operation to perform on the module
- * @param u User who requested the operation
- **/
-void queueModuleOperation(Module *m, ModuleOperation op, User *u)
-{
- ModuleQueue *qm;
-
- qm = (ModuleQueue *)scalloc(1, sizeof(ModuleQueue));
- qm->m = m;
- qm->op = op;
- qm->u = u;
- qm->next = mod_operation_queue;
- mod_operation_queue = qm;
-}
-
-/**
- * Enqueue a module to load
- * @param name Name of the module to load
- * @param u User who requested the load
- * @return 1 on success, 0 on error
- **/
-int queueModuleLoad(char *name, User *u)
-{
- Module *m;
-
- if (!name || !u)
- return 0;
-
- if (findModule(name))
- return 0;
- m = createModule(name);
- queueModuleOperation(m, MOD_OP_LOAD, u);
-
- return 1;
-}
-
-/**
- * Enqueue a module to unload
- * @param name Name of the module to unload
- * @param u User who requested the unload
- * @return 1 on success, 0 on error
- **/
-int queueModuleUnload(char *name, User *u)
-{
- Module *m;
-
- if (!name || !u)
- return 0;
-
- m = findModule(name);
- if (!m)
- return 0;
- queueModuleOperation(m, MOD_OP_UNLOAD, u);
-
- return 1;
-}
-
-/**
- * Execute all queued module operations
- **/
-void handleModuleOperationQueue(void)
-{
- ModuleQueue *next;
- int status;
-
- if (!mod_operation_queue)
- return;
-
- while (mod_operation_queue) {
- next = mod_operation_queue->next;
-
- mod_current_module = mod_operation_queue->m;
- mod_current_user = mod_operation_queue->u;
-
- if (mod_operation_queue->op == MOD_OP_LOAD) {
- alog("Trying to load module [%s]", mod_operation_queue->m->name);
- status = loadModule(mod_operation_queue->m, mod_operation_queue->u);
- alog("Module loading status: %d (%s)", status, ModuleGetErrStr(status));
- if (status != MOD_ERR_OK) {
- if(mod_current_user) {
- notice_lang(s_OperServ, mod_current_user, OPER_MODULE_LOAD_FAIL,mod_operation_queue->m->name);
- }
- destroyModule(mod_operation_queue->m);
- }
- } else if (mod_operation_queue->op == MOD_OP_UNLOAD) {
- alog("Trying to unload module [%s]", mod_operation_queue->m->name);
- status = unloadModule(mod_operation_queue->m, mod_operation_queue->u);
- alog("Module unloading status: %d (%s)", status, ModuleGetErrStr(status));
- }
-
- /* Remove the ModuleQueue from memory */
- free(mod_operation_queue);
-
- mod_operation_queue = next;
- }
-
- mod_current_module = NULL;
- mod_current_user = NULL;
-}
-
void ModuleRunTimeDirCleanUp(void)
{
#ifndef _WIN32
diff --git a/src/process.c b/src/process.c
index e75b444bc..3f2348097 100644
--- a/src/process.c
+++ b/src/process.c
@@ -427,9 +427,6 @@ void process()
alog("debug: unknown message from server (%s)", inbuf);
}
- /* Load/unload modules if needed */
- handleModuleOperationQueue();
-
/* Free argument list we created */
free(av);
}