CSocket::~CSocket() { CUser *pUser = nullptr; // CWebSock could cause us to have a nullptr pointer here if (m_pModule) { pUser = m_pModule->GetUser(); m_pModule->UnlinkSocket(this); } if (pUser && m_pModule && (m_pModule->GetType() != CModInfo::GlobalModule)) { pUser->AddBytesWritten(GetBytesWritten()); pUser->AddBytesRead(GetBytesRead()); } else { CZNC::Get().AddBytesWritten(GetBytesWritten()); CZNC::Get().AddBytesRead(GetBytesRead()); } }
CClient::~CClient() { if (!m_spAuth.IsNull()) { CClientAuth* pAuth = (CClientAuth*) &(*m_spAuth); pAuth->Invalidate(); } if (m_pUser != NULL) { m_pUser->AddBytesRead(GetBytesRead()); m_pUser->AddBytesWritten(GetBytesWritten()); } }
CWebSock::~CWebSock() { if (!m_spAuth.IsNull()) { m_spAuth->Invalidate(); } // we have to account for traffic here because CSocket does // not have a valid CModule* pointer. CUser *pUser = GetSession()->GetUser(); if (pUser) { pUser->AddBytesWritten(GetBytesWritten()); pUser->AddBytesRead(GetBytesRead()); } else { CZNC::Get().AddBytesWritten(GetBytesWritten()); CZNC::Get().AddBytesRead(GetBytesRead()); } // bytes have been accounted for, so make sure they don't get again: ResetBytesWritten(); ResetBytesRead(); }
CSocket::~CSocket() { CUser *pUser = nullptr; CIRCNetwork* pNetwork = nullptr; // CWebSock could cause us to have a nullptr pointer here if (m_pModule) { pUser = m_pModule->GetUser(); pNetwork = m_pModule->GetNetwork(); m_pModule->UnlinkSocket(this); } if (pNetwork && m_pModule && (m_pModule->GetType() == CModInfo::NetworkModule)) { pNetwork->AddBytesWritten(GetBytesWritten()); pNetwork->AddBytesRead(GetBytesRead()); } else if (pUser && m_pModule && (m_pModule->GetType() == CModInfo::UserModule)) { pUser->AddBytesWritten(GetBytesWritten()); pUser->AddBytesRead(GetBytesRead()); } else { CZNC::Get().AddBytesWritten(GetBytesWritten()); CZNC::Get().AddBytesRead(GetBytesRead()); } }
CIRCSock::~CIRCSock() { const vector<CChan*>& vChans = m_pUser->GetChans(); for (unsigned int a = 0; a < vChans.size(); a++) { vChans[a]->Reset(); } m_pUser->IRCDisconnected(); for (map<CString, CChan*>::iterator a = m_msChans.begin(); a != m_msChans.end(); ++a) { delete a->second; } if (!m_bISpoofReleased) { CZNC::Get().ReleaseISpoof(); } Quit(); m_msChans.clear(); GetUser()->AddBytesRead(GetBytesRead()); GetUser()->AddBytesWritten(GetBytesWritten()); }
CIRCSock::~CIRCSock() { if (!m_bAuthed) { NETWORKMODULECALL(OnIRCConnectionError(this), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); } const vector<CChan*>& vChans = m_pNetwork->GetChans(); for (unsigned int a = 0; a < vChans.size(); a++) { vChans[a]->Reset(); } m_pNetwork->IRCDisconnected(); for (map<CString, CChan*>::iterator a = m_msChans.begin(); a != m_msChans.end(); ++a) { delete a->second; } Quit(); m_msChans.clear(); m_pNetwork->GetUser()->AddBytesRead(GetBytesRead()); m_pNetwork->GetUser()->AddBytesWritten(GetBytesWritten()); }
BOOL CXmlFile::SaveEx() { if (GetFileHandle() == (HANDLE)CStdioFileEx::hFileNull) return FALSE; BOOL bRes = FALSE; CString sXml; if (Export(sXml)) { try { // move to start Seek(0, CStdioFileEx::begin); // write the xml CStdioFileEx::WriteString((LPCTSTR)sXml); // update the file end VERIFY(::SetEndOfFile(GetFileHandle())); // verify file length matches length of xml DWORD dwFileSizeInBytes = ::GetFileSize(GetFileHandle(), NULL); DWORD dwXmlSizeInBytes = GetBytesWritten(); if (dwFileSizeInBytes == dwXmlSizeInBytes) bRes = TRUE; } catch (...) { m_nFileError = GetLastError(); } } return bRes; }