From 13aeb82ad2462d3eb2952365fd944c8837d55ea8 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 3 Sep 2006 00:58:09 +0000 Subject: Proper error checking on loading cmd_*.so files git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5122 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/command_parse.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 83f4674c4..9b5dc5316 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -475,15 +475,16 @@ CommandParser::CommandParser(InspIRCd* Instance) : ServerInstance(Instance) this->SetupCommandTable(); } -void CommandParser::FindSym(void** v, void* h) +bool CommandParser::FindSym(void** v, void* h) { *v = dlsym(h, "init_command"); const char* err = dlerror(); if (err) { - printf("ERROR: %s\n",err); - exit(0); + ServerInstance->Log(SPARSE, "Error loading core command: %s\n", err); + return false; } + return true; } bool CommandParser::ReloadCommand(const char* cmd) @@ -542,13 +543,16 @@ void CommandParser::LoadCommand(const char* name) h = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); if (!h) + { + ServerInstance->Log(SPARSE, "Error loading core command: %s", dlerror()); return; + } - this->FindSym((void **)&cmd_factory_func, h); - - command_t* newcommand = cmd_factory_func(ServerInstance); - - this->CreateCommand(newcommand, h); + if (this->FindSym((void **)&cmd_factory_func, h)) + { + command_t* newcommand = cmd_factory_func(ServerInstance); + this->CreateCommand(newcommand, h); + } } void CommandParser::SetupCommandTable() -- cgit v1.2.3