Permalink
Browse files

Unload user and network modules once all the clients are gone and we …

…are disconencted from any IRC servers.

The OnIRCDisconnected module call would cause a segmentation fault
because it would try m_pNetwork->GetModules().GetNetwork(). GetModules()
would return NULL.
  • Loading branch information...
1 parent 75d7cdf commit bf8b1624c92c2553312161d5806a2042cee38962 @kylef kylef committed Aug 31, 2011
Showing with 8 additions and 8 deletions.
  1. +4 −4 IRCNetwork.cpp
  2. +4 −4 User.cpp
View
8 IRCNetwork.cpp
@@ -134,10 +134,6 @@ CIRCNetwork::CIRCNetwork(CUser *pUser, const CIRCNetwork *pNetwork, bool bCloneC
}
CIRCNetwork::~CIRCNetwork() {
- // Delete modules (this unloads all modules)
- delete m_pModules;
- m_pModules = NULL;
-
// Delete clients
for (vector<CClient*>::const_iterator it = m_vClients.begin(); it != m_vClients.end(); ++it) {
CZNC::Get().GetManager().DelSockByAddr(*it);
@@ -147,6 +143,10 @@ CIRCNetwork::~CIRCNetwork() {
// Delete servers
DelServers();
+ // Delete modules (this unloads all modules)
+ delete m_pModules;
+ m_pModules = NULL;
+
// Delete Channels
for (vector<CChan*>::const_iterator it = m_vChans.begin(); it != m_vChans.end(); ++it) {
delete *it;
View
8 User.cpp
@@ -88,10 +88,6 @@ CUser::CUser(const CString& sUserName)
}
CUser::~CUser() {
- // Delete modules (unloads all modules!)
- delete m_pModules;
- m_pModules = NULL;
-
// Delete networks
for (unsigned int c = 0; c < m_vIRCNetworks.size(); c++) {
CIRCNetwork* pNetwork = m_vIRCNetworks[c];
@@ -106,6 +102,10 @@ CUser::~CUser() {
}
m_vClients.clear();
+ // Delete modules (unloads all modules!)
+ delete m_pModules;
+ m_pModules = NULL;
+
CZNC::Get().GetManager().DelCronByAddr(m_pUserTimer);
CZNC::Get().AddBytesRead(BytesRead());

0 comments on commit bf8b162

Please sign in to comment.