aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree/treesocket1.cpp
diff options
context:
space:
mode:
authorGravatar danieldg2009-05-07 14:51:10 +0000
committerGravatar danieldg2009-05-07 14:51:10 +0000
commitb2159a9e4f40fcbe755f8c0d2e6a7cbfcfd09f4f (patch)
tree9c80d4742519339edfbc66d439c6b05390f0c762 /src/modules/m_spanningtree/treesocket1.cpp
parentCompile fix: openssl does not have an ISSL_CLOSING state, unlike gnutls (diff)
Remove handshake timer on server sockets that die before completing handshake
This fixes some very subtle and hard-to-trace bugs that are triggered when a file descriptor and memory address of an EventHandler* are reused after being deallocated. Impossible to trigger in valgrind; has been seen in live networks. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11369 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree/treesocket1.cpp')
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 12272d3b8..d0db01dec 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -46,6 +46,7 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, std::string sh
Utils->timeoutlist[this] = std::pair<std::string, int>(ServerName, maxtime);
if (Hook)
BufferedSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send();
+ hstimer = NULL;
}
/** When a listening socket gives us a new file descriptor,
@@ -65,7 +66,8 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, int newfd, cha
if (Hook)
BufferedSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send();
- ServerInstance->Timers->AddTimer(new HandshakeTimer(ServerInstance, this, &(Utils->LinkBlocks[0]), this->Utils, 1));
+ hstimer = new HandshakeTimer(ServerInstance, this, &(Utils->LinkBlocks[0]), this->Utils, 1);
+ ServerInstance->Timers->AddTimer(hstimer);
/* Fix by Brain - inbound sockets need a timeout, too. 30 secs should be pleanty */
Utils->timeoutlist[this] = std::pair<std::string, int>("<unknown>", 30);
@@ -85,6 +87,8 @@ TreeSocket::~TreeSocket()
{
if (Hook)
BufferedSocketUnhookRequest(this, (Module*)Utils->Creator, Hook).Send();
+ if (hstimer)
+ ServerInstance->Timers->DelTimer(hstimer);
Utils->timeoutlist.erase(this);
}
@@ -115,7 +119,10 @@ bool TreeSocket::OnConnected()
/* found who we're supposed to be connecting to, send the neccessary gubbins. */
if (this->GetHook())
- ServerInstance->Timers->AddTimer(new HandshakeTimer(ServerInstance, this, &(*x), this->Utils, 1));
+ {
+ hstimer = new HandshakeTimer(ServerInstance, this, &(*x), this->Utils, 1);
+ ServerInstance->Timers->AddTimer(hstimer);
+ }
else
this->SendCapabilities();