summaryrefslogtreecommitdiff
path: root/src/socket.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-11 18:02:11 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-11 18:02:11 +0000
commit57e27d97fa28e30de04a1db2c33bb3286f0fe1d5 (patch)
treef292c9ae517f1f5edeb86258a17c1e2138f8589f /src/socket.cpp
parentb00a72d3aafb3a2dd5edbc388b06ffc2ff5540d4 (diff)
Fixes
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3669 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socket.cpp')
-rw-r--r--src/socket.cpp16
1 files changed, 13 insertions, 3 deletions
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)