Add /msg *status UpdateMod[ule] which reloads an user module on all users

This command allows admins to really reload a module when they have updated it.
Because the dynamic linker does not really reload a shared object until all
handles to this object where dlclose()'d, this new command is necessary.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1418 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-03-09 17:37:35 +00:00
parent 994da49638
commit c3e4a7a1e7
3 changed files with 56 additions and 0 deletions
+27
View File
@@ -80,6 +80,33 @@ void CUser::DelModules() {
m_pModules = NULL;
}
}
bool CUser::UpdateModule(const CString &sModule) {
const map<CString,CUser*>& Users = CZNC::Get().GetUserMap();
map<CString,CUser*>::const_iterator it;
map<CUser*, CString> Affected;
map<CUser*, CString>::iterator it2;
bool error = false;
for (it = Users.begin(); it != Users.end(); it++) {
CModule *pMod = it->second->GetModules().FindModule(sModule);
if (pMod) {
Affected[it->second] = pMod->GetArgs();
it->second->GetModules().UnloadModule(pMod->GetModName());
}
}
CString sErr;
for (it2 = Affected.begin(); it2 != Affected.end(); it2++) {
if (!it2->first->GetModules().LoadModule(sModule, it2->second, it2->first, sErr)) {
error = true;
DEBUG("Failed to reload [" << sModule << "] for [" << it2->first->GetUserName()
<< "]: " << sErr);
}
}
return !error;
}
#endif
void CUser::DelClients() {