From 9ca3a5fdad9c865b990540f30315e69fed03546a Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 13 Oct 2007 22:50:34 +0000 Subject: More fixes to the ident stuff to make sure that one socket doesnt go before the other, without the one thats left knowing its gone! git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8166 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_ident.cpp | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index eb1959c86..9272c5054 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -57,7 +57,7 @@ class IdentRequestSocket : public InspSocket if ((getsockname(user->GetFd(), (sockaddr*) &laddr, &laddrsz) != 0) || (getpeername(user->GetFd(), (sockaddr*) &raddr, &raddrsz) != 0)) { // Error - user->Shrink("ident_socket"); + TidyUser(); return false; } @@ -91,7 +91,7 @@ class IdentRequestSocket : public InspSocket if (*user->ident == '~' && user->GetExt("ident_socket")) user->WriteServ("NOTICE Auth :*** Could not find your ident, using %s instead", user->ident); - user->Shrink("ident_socket"); + TidyUser(); Instance->next_call = Instance->Time(); } @@ -107,7 +107,7 @@ class IdentRequestSocket : public InspSocket if (*user->ident == '~' && user->GetExt("ident_socket")) user->WriteServ("NOTICE Auth :*** Could not find your ident, using %s instead", user->ident); - user->Shrink("ident_socket"); + TidyUser(); Instance->next_call = Instance->Time(); } @@ -121,7 +121,10 @@ class IdentRequestSocket : public InspSocket char *ibuf = this->Read(); if (!ibuf) + { + TidyUser(); return false; + } // We don't really need to buffer for incomplete replies here, since IDENT replies are // extremely short - there is *no* sane reason it'd be in more than one packet @@ -166,9 +169,20 @@ class IdentRequestSocket : public InspSocket break; } - user->Shrink("ident_socket"); + TidyUser(); return false; } + + void TidyUser() + { + user->Shrink("ident_socket"); + int* delfd; + if (user->GetExt("ident_socket_fd", delfd)) + { + delete delfd; + user->Shrink("ident_socket_fd"); + } + } }; class ModuleIdent : public Module @@ -239,7 +253,10 @@ class ModuleIdent : public Module IdentRequestSocket *isock = new IdentRequestSocket(ServerInstance, user, RequestTimeout, ip); if (isock->GetFd() > -1) + { + user->Extend("ident_socket_fd", new int(isock->GetFd())); user->Extend("ident_socket", isock); + } else if (ServerInstance->SocketCull.find(isock) == ServerInstance->SocketCull.end()) ServerInstance->SocketCull[isock] = isock; @@ -258,7 +275,11 @@ class ModuleIdent : public Module IdentRequestSocket *isock; userrec *user = (userrec*)item; if (user->GetExt("ident_socket", isock)) - isock->Close(); + { + int *fd; + if (user->GetExt("ident_socket_fd", fd) && (ServerInstance->SE->GetRef(*fd) == isock)) + isock->Close(); + } } } @@ -266,8 +287,13 @@ class ModuleIdent : public Module { IdentRequestSocket *isock; if (user->GetExt("ident_socket", isock)) - isock->Close(); + { + int *fd; + if (user->GetExt("ident_socket_fd", fd) && (ServerInstance->SE->GetRef(*fd) == isock)) + isock->Close(); + } } }; MODULE_INIT(ModuleIdent); + -- cgit v1.2.3