diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-11 18:02:11 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-11 18:02:11 +0000 |
commit | 57e27d97fa28e30de04a1db2c33bb3286f0fe1d5 (patch) | |
tree | f292c9ae517f1f5edeb86258a17c1e2138f8589f /src | |
parent | b00a72d3aafb3a2dd5edbc388b06ffc2ff5540d4 (diff) |
Fixes
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3669 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules.cpp | 12 | ||||
-rw-r--r-- | src/socket.cpp | 16 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index 5847e6054..529946220 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -328,17 +328,7 @@ void Server::RemoveSocket(InspSocket* sock) { InspSocket* s = (InspSocket*)*a; if (s == sock) - { - s->Close(); - /* - log(DEBUG,"Forcibly removed socket"); - ServerInstance->SE->DelFd(s->GetFd()); - log(DEBUG,"Delete Fd from socket engine"); - s->Close(); - module_sockets.erase(a); - delete s; - return;*/ - } + s->MarkAsClosed(); } } diff --git a/src/socket.cpp b/src/socket.cpp index 23d760002..2f8030d7f 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -48,6 +48,7 @@ InspSocket::InspSocket() { this->state = I_DISCONNECTED; this->fd = -1; + this->ClosePending = false; } InspSocket::InspSocket(int newfd, char* ip) @@ -55,13 +56,14 @@ InspSocket::InspSocket(int newfd, char* ip) this->fd = newfd; this->state = I_CONNECTED; this->IP = ip; + this->ClosePending = false; ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE); socket_ref[this->fd] = this; } -InspSocket::InspSocket(const std::string &ahost, int aport, bool listening, unsigned long maxtime) - : fd(-1), host(ahost) +InspSocket::InspSocket(const std::string &ahost, int aport, bool listening, unsigned long maxtime) : fd(-1), host(ahost) { + this->ClosePending = false; this->outbuffer.clear(); if (listening) { if ((this->fd = OpenTCPSocket()) == ERROR) @@ -240,6 +242,11 @@ char* InspSocket::Read() } } +void InspSocket::MarkAsClosed() +{ + this->ClosePending = true; +} + // There are two possible outcomes to this function. // It will either write all of the data, or an undefined amount. // If an undefined amount is written the connection has failed @@ -290,6 +297,9 @@ bool InspSocket::Timeout(time_t current) if (!socket_ref[this->fd] || !ServerInstance->SE->HasFd(this->fd)) return false; + if (this->ClosePending) + return true; + if (((this->state == I_RESOLVING) || (this->state == I_CONNECTING)) && (current > timeout_end)) { log(DEBUG,"Timed out, current=%lu timeout_end=%lu"); @@ -314,7 +324,7 @@ bool InspSocket::Poll() int incoming = -1; bool n = true; - if ((fd < 0) || (fd > MAX_DESCRIPTORS)) + if ((fd < 0) || (fd > MAX_DESCRIPTORS) || (this->ClosePending)) return false; switch (this->state) |