summaryrefslogtreecommitdiff
path: root/src/command_parse.cpp
diff options
context:
space:
mode:
authorGravatar brain2007-08-11 12:17:40 +0000
committerGravatar brain2007-08-11 12:17:40 +0000
commit76ded2a428a56b775f41293e6fd0f3666bf8b614 (patch)
treedc064553bf7dce04b252225f87b1a788cb00262d /src/command_parse.cpp
parentbp: Make the return codes correct, and allow for LoadCommand without a user p... (diff)
Fix this so it works.
OBVIOUS WARNING FOR THE DUMB: Dont go overwriting .so files at random to test this, you WILL crash your ircd if you do this improprerly, this is a feature of the linux shared object loader. If you want to test this, try with: rm cmd_whatever.so && echo "TESTTEST" >cmd_whatever.so, do NOT just do the echo. git-svn-id: http://svn.inspircd.org/repository/branches/1_1_stable@7714 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/command_parse.cpp')
-rw-r--r--src/command_parse.cpp43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 2c2e2361e..10c22dbfb 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -447,7 +447,6 @@ bool CommandParser::CreateCommand(command_t *f, void* so_handle)
CommandParser::CommandParser(InspIRCd* Instance) : ServerInstance(Instance)
{
para.resize(128);
- this->SetupCommandTable();
}
bool CommandParser::FindSym(void** v, void* h)
@@ -514,7 +513,7 @@ CmdResult cmd_reload::Handle(const char** parameters, int pcnt, userrec *user)
}
else
{
- user->WriteServ("NOTICE %s :*** Could not reload command '%s'", user->nick, parameters[0]);
+ user->WriteServ("NOTICE %s :*** Could not reload command '%s' -- fix this problem, then /REHASH as soon as possible!", user->nick, parameters[0]);
return CMD_FAILURE;
}
}
@@ -525,6 +524,13 @@ const char* CommandParser::LoadCommand(const char* name)
void* h;
command_t* (*cmd_factory_func)(InspIRCd*);
+ /* Command already exists? Succeed silently - this is needed for REHASH */
+ if (RFCCommands.find(name) != RFCCommands.end())
+ {
+ ServerInstance->Log(DEBUG,"Not reloading command %s/%s, it already exists", LIBRARYDIR, name);
+ return NULL;
+ }
+
snprintf(filename, MAXBUF, "%s/%s", LIBRARYDIR, name);
h = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
@@ -543,12 +549,15 @@ const char* CommandParser::LoadCommand(const char* name)
return NULL;
}
-void CommandParser::SetupCommandTable()
+void CommandParser::SetupCommandTable(userrec* user)
{
RFCCommands.clear();
- printf("\nLoading core commands");
- fflush(stdout);
+ if (!user)
+ {
+ printf("\nLoading core commands");
+ fflush(stdout);
+ }
DIR* library = opendir(LIBRARYDIR);
if (library)
@@ -558,20 +567,32 @@ void CommandParser::SetupCommandTable()
{
if (match(entry->d_name, "cmd_*.so"))
{
- printf(".");
- fflush(stdout);
+ if (!user)
+ {
+ printf(".");
+ fflush(stdout);
+ }
const char* err = this->LoadCommand(entry->d_name);
if (err)
{
- printf("Error loading %s: %s", entry->d_name, err);
- exit(EXIT_STATUS_BADHANDLER);
+ if (user)
+ {
+ user->WriteServ("NOTICE %s :*** Failed to load core command %s: %s", user->nick, entry->d_name, err);
+ }
+ else
+ {
+ printf("Error loading %s: %s", entry->d_name, err);
+ exit(EXIT_STATUS_BADHANDLER);
+ }
}
}
}
closedir(library);
- printf("\n");
+ if (!user)
+ printf("\n");
}
- this->CreateCommand(new cmd_reload(ServerInstance));
+ if (cmdlist.find("RELOAD") == cmdlist.end())
+ this->CreateCommand(new cmd_reload(ServerInstance));
}