Exemple #1
0
CIRCNetwork::~CIRCNetwork() {
    if (m_pIRCSock) {
        CZNC::Get().GetManager().DelSockByAddr(m_pIRCSock);
        m_pIRCSock = nullptr;
    }

    // Delete clients
    while (!m_vClients.empty()) {
        CZNC::Get().GetManager().DelSockByAddr(m_vClients[0]);
    }
    m_vClients.clear();

    // Delete servers
    DelServers();

    // Delete modules (this unloads all modules)
    delete m_pModules;
    m_pModules = nullptr;

    // Delete Channels
    for (CChan* pChan : m_vChans) {
        delete pChan;
    }
    m_vChans.clear();

    // Delete Queries
    for (CQuery* pQuery : m_vQueries) {
        delete pQuery;
    }
    m_vQueries.clear();

    CUser* pUser = GetUser();
    SetUser(nullptr);

    // Make sure we are not in the connection queue
    CZNC::Get().GetConnectionQueue().remove(this);

    CZNC::Get().GetManager().DelCronByAddr(m_pPingTimer);
    CZNC::Get().GetManager().DelCronByAddr(m_pJoinTimer);

    if (pUser) {
        pUser->AddBytesRead(m_uBytesRead);
        pUser->AddBytesWritten(m_uBytesWritten);
    } else {
        CZNC::Get().AddBytesRead(m_uBytesRead);
        CZNC::Get().AddBytesWritten(m_uBytesWritten);
    }
}
Exemple #2
0
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());
	}
}
Exemple #3
0
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();
}
Exemple #4
0
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());
	}
}