Remove bogus "Unable to find module" from modperl.

When a module tries to being loaded, modperl looks for module.pm file.
If there's no such file, it said "unable to find", which is bad
in case when it's non-perl module.

Loader of C++ modules clears sRetMsg string, so the message wasn't seen before
(except debug and ZNC startup). But modpython does nothing with it
(if python module doesn't set it itself), so in result we get stuff like
"Loaded module [xxx] [Unable to find module [xxx]] [/home/user/.znc/modules/xxx.py]"
which is pretty confusing.

So now if perl version of the module isn't found, we just pass control to next
available module loader without any error messages.

Thanks to macmaN for reporting this.
This commit is contained in:
Alexey Sokolov
2011-03-21 11:17:27 +06:00
parent 9506d7e32b
commit e62ec2dc82
2 changed files with 30 additions and 34 deletions

View File

@@ -73,44 +73,40 @@ public:
return true;
}
ELoadPerlMod LoadPerlModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg) {
ELoadPerlMod result = Perl_LoadError;
PSTART;
PUSH_STR(sModule);
PUSH_STR(sArgs);
PUSH_PTR(CUser*, pUser);
PCALL("ZNC::Core::LoadModule");
if (SvTRUE(ERRSV)) {
sRetMsg = PString(ERRSV);
} else if (2 == ret) {
result = static_cast<ELoadPerlMod>(SvUV(ST(0)));
sRetMsg = PString(ST(1));
}
DEBUG(__PRETTY_FUNCTION__ << " " << sRetMsg);
PEND;
return result;
}
virtual EModRet OnModuleLoading(const CString& sModName, const CString& sArgs,
bool& bSuccess, CString& sRetMsg) {
if (!GetUser()) {
return CONTINUE;
}
switch (LoadPerlModule(sModName, sArgs, GetUser(), sRetMsg)) {
case Perl_NotFound:
return CONTINUE;
case Perl_Loaded:
bSuccess = true;
return HALT;
case Perl_LoadError:
bSuccess = false;
return HALT;
EModRet result = HALT;
PSTART;
PUSH_STR(sModName);
PUSH_STR(sArgs);
PUSH_PTR(CUser*, GetUser());
PCALL("ZNC::Core::LoadModule");
if (SvTRUE(ERRSV)) {
sRetMsg = PString(ERRSV);
bSuccess = false;
result = HALT;
DEBUG("Perl ZNC::Core::LoadModule died: " << sRetMsg);
} else if (ret < 1 || 2 < ret) {
sRetMsg = "Error: Perl ZNC::Core::LoadModule returned " + CString(ret) + " values.";
bSuccess = false;
result = HALT;
} else {
ELoadPerlMod eLPM = static_cast<ELoadPerlMod>(SvUV(ST(0)));
if (Perl_NotFound == eLPM) {
result = CONTINUE; // Not a Perl module
} else {
sRetMsg = PString(ST(1));
result = HALT;
bSuccess = eLPM == Perl_Loaded;
}
}
sRetMsg = "Something weird happened";
bSuccess = false;
return HALT;
PEND;
return result;
}
virtual EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg) {