Skip to content

Commit

Permalink
Merge to stable
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.inspircd.org/repository/branches/1_1_stable@8168 e03df62e-2008-0410-955e-edbf42e46eb7
  • Loading branch information
braindigitalis committed Oct 13, 2007
1 parent 8a945f4 commit 438bec9
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions src/modules/m_ident.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -258,16 +275,33 @@ 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))
{
user->Shrink("ident_socket_fd");
delete fd;
isock->Close();
}
}
}
}

virtual void OnUserDisconnect(userrec *user)
{
IdentRequestSocket *isock;
if (user->GetExt("ident_socket", isock))
isock->Close();
{
int *fd;
if (user->GetExt("ident_socket_fd", fd) && (ServerInstance->SE->GetRef(*fd) == isock))
{
user->Shrink("ident_socket_fd");
delete fd;
isock->Close();
}
}
}
};

MODULE_INIT(ModuleIdent);

0 comments on commit 438bec9

Please sign in to comment.