summaryrefslogtreecommitdiff
path: root/src/socket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/socket.cpp')
-rw-r--r--src/socket.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index d4cdb0a18..f4e6a5a6a 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -147,6 +147,7 @@ bool InspSocket::DoResolve()
this->Close();
this->state = I_ERROR;
this->OnError(I_ERR_RESOLVE);
+ this->fd = -1;
return false;
}
return this->DoConnect();
@@ -163,6 +164,7 @@ bool InspSocket::DoConnect()
log(DEBUG,"Cant socket()");
this->state = I_ERROR;
this->OnError(I_ERR_SOCKET);
+ this->fd = -1;
return false;
}
@@ -184,6 +186,7 @@ bool InspSocket::DoConnect()
this->OnError(I_ERR_CONNECT);
this->state = I_ERROR;
this->Close();
+ this->fd = -1;
return false;
}
}
@@ -275,6 +278,7 @@ bool InspSocket::FlushWriteBuffer()
log(DEBUG,"Write error on socket: %s",strerror(errno));
this->OnError(I_ERR_WRITE);
this->state = I_ERROR;
+ this->fd = -1;
return true;
}
}
@@ -295,6 +299,7 @@ bool InspSocket::Timeout(time_t current)
this->OnError(I_ERR_TIMEOUT);
timeout = true;
this->state = I_ERROR;
+ this->fd = -1;
return true;
}
return this->FlushWriteBuffer();
@@ -305,6 +310,9 @@ bool InspSocket::Poll()
int incoming = -1;
bool n = true;
+ if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ return false;
+
switch (this->state)
{
case I_RESOLVING: