Exemple #1
0
	virtual ~CModPython() {
		const map<CString, CUser*>& users = CZNC::Get().GetUserMap();
		for (map<CString, CUser*>::const_iterator i = users.begin(); i != users.end(); ++i) {
			CModules& M = i->second->GetModules();
			bool cont;
			do {
				cont = false;
				for (CModules::iterator it = M.begin(); it != M.end(); ++it) {
					CModule* m = *it;
					CPyModule* mod = AsPyModule(m);
					if (mod) {
						cont = true;
						bool bSuccess = false;
						CString sRetMsg;
						OnModuleUnloading(mod, bSuccess, sRetMsg);
						if (!bSuccess) {
							DEBUG("Error unloading python module in ~CModPython: " << sRetMsg);
						}
						break;
					}
				}
			} while (cont);
		}
		Py_CLEAR(m_PyFormatException);
		Py_CLEAR(m_PyZNCModule);
		Py_Finalize();
	}
bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) {
    CString sMod = sModule;  // Make a copy incase the reference passed in is from CModule::GetModName()
    CModule* pModule = FindModule(sMod);
    sRetMsg = "";

    if (!pModule) {
        sRetMsg = "Module [" + sMod + "] not loaded.";
        return false;
    }

    bool bSuccess;
    GLOBALMODULECALL(OnModuleUnloading(pModule, bSuccess, sRetMsg), pModule->GetUser(), NULL, return bSuccess);

    ModHandle p = pModule->GetDLL();

    if (p) {
        delete pModule;

        for (iterator it = begin(); it != end(); ++it) {
            if (*it == pModule) {
                erase(it);
                break;
            }
        }

        dlclose(p);
        sRetMsg = "Module [" + sMod + "] unloaded";

        return true;
    }

    sRetMsg = "Unable to unload module [" + sMod + "]";
    return false;
}
Exemple #3
0
bool CGlobalModules::OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg) {
	GLOBALMODHALTCHK(OnModuleUnloading(pModule, bSuccess, sRetMsg));
}