Permalink
Browse files

Fix #293

In GetAvailableMods() modules paths were returned like "moddir//module.pm",
but when they are loaded, they use path "moddir/module.pm".

Because of that our hack of cleaning %INC when the module is unloaded,
which enables UpdateMod, removed wrong record from %INC, left right
record in it, and erased the module's namespace.

When the module was loaded again, the namespace was not restored,
because "require" didn't load the module, because it was still in %INC.

So, when we call a function of that module, the function does not exist
anymore.
  • Loading branch information...
1 parent 53c579b commit 9f4f2817d17deacbe7d8e99d31471e8e4e0f868a @DarthGandalf DarthGandalf committed Mar 16, 2013
Showing with 9 additions and 2 deletions.
  1. +1 −1 include/znc/FileUtils.h
  2. +3 −1 modules/modperl.cpp
  3. +5 −0 modules/modperl/startup.pl
View
@@ -187,7 +187,7 @@ class CDir : public std::vector<CFile*> {
continue;
}
- CFile *file = new CFile(sDir + "/" + de->d_name/*, this*/); // @todo need to pass pointer to 'this' if we want to do Sort()
+ CFile *file = new CFile(sDir.TrimSuffix_n("/") + "/" + de->d_name/*, this*/); // @todo need to pass pointer to 'this' if we want to do Sort()
push_back(file);
}
View
@@ -211,7 +211,9 @@ class CModPerl: public CModule {
PUSH_STR(sName);
PUSH_PTR(CModInfo*, &ModInfo);
PCALL("ZNC::Core::ModInfoByPath");
- if (!SvTRUE(ERRSV)) {
+ if (SvTRUE(ERRSV)) {
+ DEBUG(__PRETTY_FUNCTION__ << ": " << sPath << ": " << PString(ERRSV));
+ } else if (ModInfo.SupportsType(eType)) {
ssMods.insert(ModInfo);
}
PEND;
@@ -162,6 +162,11 @@ sub ModInfoByPath {
$modinfo->SetName($modname);
$modinfo->SetPath($modpath);
$modinfo->AddType($_) for @types;
+ unless ($modrefcount{$modname}) {
+ say "Unloading $modpath from perl, because it's not loaded as a module";
+ ZNC::_CleanupStash($modname);
+ delete $INC{$modpath};
+ }
}
sub CallModFunc {

0 comments on commit 9f4f281

Please sign in to comment.