mirror of
https://github.com/znc/znc.git
synced 2026-07-03 00:11:59 +02:00
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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user