diff --git a/DCCBounce.cpp b/DCCBounce.cpp index e07104a5..b2f43f7f 100644 --- a/DCCBounce.cpp +++ b/DCCBounce.cpp @@ -32,6 +32,8 @@ CDCCBounce::CDCCBounce(CUser* pUser, unsigned long uLongIP, unsigned short uPort if (bIsChat) { EnableReadLine(); } + + m_pUser->AddDCCBounce(this); } CDCCBounce::CDCCBounce(const CString& sHostname, unsigned short uPort, CUser* pUser, @@ -50,6 +52,8 @@ CDCCBounce::CDCCBounce(const CString& sHostname, unsigned short uPort, CUser* pU if (bIsChat) { EnableReadLine(); } + + m_pUser->AddDCCBounce(this); } CDCCBounce::~CDCCBounce() { @@ -57,10 +61,11 @@ CDCCBounce::~CDCCBounce() { m_pPeer->Shutdown(); m_pPeer = NULL; } - if (m_pUser) { - m_pUser->AddBytesRead(GetBytesRead()); - m_pUser->AddBytesWritten(GetBytesWritten()); - } + + m_pUser->AddBytesRead(GetBytesRead()); + m_pUser->AddBytesWritten(GetBytesWritten()); + + m_pUser->DelDCCBounce(this); } void CDCCBounce::ReadLine(const CString& sData) { diff --git a/DCCSock.cpp b/DCCSock.cpp index d3ecfaf5..0090c51a 100644 --- a/DCCSock.cpp +++ b/DCCSock.cpp @@ -10,15 +10,49 @@ #include "User.h" #include "Utils.h" +CDCCSock::CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sLocalFile, const CString& sModuleName, + unsigned long uFileSize, CFile* pFile) : CZNCSock() { + m_sRemoteNick = sRemoteNick; + m_uFileSize = uFileSize; + m_uRemotePort = 0; + m_uBytesSoFar = 0; + m_pUser = pUser; + m_pFile = pFile; + m_sLocalFile = sLocalFile; + m_sModuleName = sModuleName; + m_bSend = true; + m_bNoDelFile = false; + + m_pUser->AddDCCSock(this); +} + +CDCCSock::CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort, + const CString& sLocalFile, unsigned long uFileSize, const CString& sModuleName) : CZNCSock() { + m_sRemoteNick = sRemoteNick; + m_sRemoteIP = sRemoteIP; + m_uRemotePort = uRemotePort; + m_uFileSize = uFileSize; + m_uBytesSoFar = 0; + m_pUser = pUser; + m_pFile = NULL; + m_sLocalFile = sLocalFile; + m_sModuleName = sModuleName; + m_bSend = false; + m_bNoDelFile = false; + + m_pUser->AddDCCSock(this); +} + CDCCSock::~CDCCSock() { if ((m_pFile) && (!m_bNoDelFile)) { m_pFile->Close(); delete m_pFile; } - if (m_pUser) { - m_pUser->AddBytesRead(GetBytesRead()); - m_pUser->AddBytesWritten(GetBytesWritten()); - } + + m_pUser->AddBytesRead(GetBytesRead()); + m_pUser->AddBytesWritten(GetBytesWritten()); + + m_pUser->DelDCCSock(this); } void CDCCSock::ReadData(const char* data, int len) { diff --git a/DCCSock.h b/DCCSock.h index 0d16763f..0d7ea3f5 100644 --- a/DCCSock.h +++ b/DCCSock.h @@ -17,42 +17,8 @@ class CUser; class CDCCSock : public CZNCSock { public: - CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sLocalFile, const CString& sModuleName, unsigned long uFileSize = 0, CFile* pFile = NULL) : CZNCSock() { - m_sRemoteNick = sRemoteNick; - m_uFileSize = uFileSize; - m_uRemotePort = 0; - m_uBytesSoFar = 0; - m_pUser = pUser; - m_pFile = pFile; - m_sLocalFile = sLocalFile; - m_sModuleName = sModuleName; - m_bSend = true; - m_bNoDelFile = false; - } - - CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort, const CString& sLocalFile, unsigned long uFileSize, const CString& sModuleName) : CZNCSock() { - m_sRemoteNick = sRemoteNick; - m_sRemoteIP = sRemoteIP; - m_uRemotePort = uRemotePort; - m_uFileSize = uFileSize; - m_uBytesSoFar = 0; - m_pUser = pUser; - m_pFile = NULL; - m_sLocalFile = sLocalFile; - m_sModuleName = sModuleName; - m_bSend = false; - m_bNoDelFile = false; - } - -/* CDCCSock(CUser* pUser, const CString& sHostname, unsigned short uPort, int iTimeout = 60) : Csock(sHostname, uPort, iTimeout) { - m_uRemotePort = 0; - m_uBytesSoFar = 0; - m_uFileSize = 0; - m_pFile = NULL; - m_pUser = pUser; - m_bNoDelFile = false; - } -*/ + CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sLocalFile, const CString& sModuleName, unsigned long uFileSize = 0, CFile* pFile = NULL); + CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort, const CString& sLocalFile, unsigned long uFileSize, const CString& sModuleName); virtual ~CDCCSock(); virtual void ReadData(const char* data, int len); diff --git a/User.cpp b/User.cpp index 8c4bc754..084a6d2b 100644 --- a/User.cpp +++ b/User.cpp @@ -69,6 +69,13 @@ CUser::~CUser() { delete m_vChans[b]; } + // This will cause an endless loop if the destructor doesn't remove the + // socket from this list / if the socket doesn't exist any more. + while (!m_sDCCBounces.empty()) + CZNC::Get().GetManager().DelSockByAddr((CZNCSock*) *m_sDCCBounces.begin()); + while (!m_sDCCSocks.empty()) + CZNC::Get().GetManager().DelSockByAddr((CZNCSock*) *m_sDCCSocks.begin()); + CZNC::Get().GetManager().DelCronByAddr(m_pJoinTimer); CZNC::Get().GetManager().DelCronByAddr(m_pMiscTimer); } diff --git a/User.h b/User.h index 3c64c807..ab8ae0a7 100644 --- a/User.h +++ b/User.h @@ -27,6 +27,8 @@ class CIRCSock; class CJoinTimer; class CMiscTimer; class CServer; +class CDCCBounce; +class CDCCSock; class CUser { public: @@ -97,6 +99,11 @@ public: void IRCDisconnected(); void CheckIRCConnect(); + void AddDCCBounce(CDCCBounce* p) { m_sDCCBounces.insert(p); } + void DelDCCBounce(CDCCBounce* p) { m_sDCCBounces.erase(p); } + void AddDCCSock(CDCCSock* p) { m_sDCCSocks.insert(p); } + void DelDCCSock(CDCCSock* p) { m_sDCCSocks.erase(p); } + CString ExpandString(const CString& sStr) const; CString& ExpandString(const CString& sStr, CString& sRet) const; @@ -246,6 +253,8 @@ protected: vector m_vServers; vector m_vChans; vector m_vClients; + set m_sDCCBounces; + set m_sDCCSocks; set m_ssAllowedHosts; unsigned int m_uServerIdx; unsigned int m_uBufferCount; diff --git a/configure b/configure index 0efe7f87..a0d6f060 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63 for znc 0.073. +# Generated by GNU Autoconf 2.63 for znc 0.074. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. @@ -594,8 +594,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='znc' PACKAGE_TARNAME='znc' -PACKAGE_VERSION='0.073' -PACKAGE_STRING='znc 0.073' +PACKAGE_VERSION='0.074' +PACKAGE_STRING='znc 0.074' PACKAGE_BUGREPORT='' ac_unique_file="znc.cpp" @@ -1246,7 +1246,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures znc 0.073 to adapt to many kinds of systems. +\`configure' configures znc 0.074 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1311,7 +1311,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of znc 0.073:";; + short | recursive ) echo "Configuration of znc 0.074:";; esac cat <<\_ACEOF @@ -1415,7 +1415,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -znc configure 0.073 +znc configure 0.074 generated by GNU Autoconf 2.63 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1429,7 +1429,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by znc $as_me 0.073, which was +It was created by znc $as_me 0.074, which was generated by GNU Autoconf 2.63. Invocation command line was $ $0 $@ @@ -3651,7 +3651,7 @@ fi appendCXX "-D_DATADIR_=\\\"${DATADIR}\\\"" fi -VERSION=0.073 +VERSION=0.074 @@ -4139,7 +4139,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by znc $as_me 0.073, which was +This file was extended by znc $as_me 0.074, which was generated by GNU Autoconf 2.63. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4189,7 +4189,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -znc config.status 0.073 +znc config.status 0.074 configured by $0, generated by GNU Autoconf 2.63, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" @@ -4802,7 +4802,7 @@ fi echo -echo znc 0.073 configured +echo znc 0.074 configured echo echo "debug: $DEBUG" echo "ipv6: $IPV6" diff --git a/configure.in b/configure.in index 919aa174..5d9618b0 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Keep the version number in sync with main.h! -AC_INIT([znc], [0.073]) +AC_INIT([znc], [0.074]) AC_CONFIG_SRCDIR([znc.cpp]) AC_LANG([C++]) diff --git a/main.h b/main.h index 4c8782e0..51933b23 100644 --- a/main.h +++ b/main.h @@ -11,7 +11,7 @@ // The following defines are for #if comparison (preprocessor only likes ints) #define VERSION_MAJOR 0 -#define VERSION_MINOR 73 +#define VERSION_MINOR 74 // This one is for display purpose #define VERSION (VERSION_MAJOR + VERSION_MINOR / 1000.0)