summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/socket.h1
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/socket.cpp12
3 files changed, 10 insertions, 5 deletions
diff --git a/include/socket.h b/include/socket.h
index b3a50f91a..6e4abf1eb 100644
--- a/include/socket.h
+++ b/include/socket.h
@@ -56,6 +56,7 @@ public:
virtual void OnClose();
virtual char* Read();
std::string GetIP();
+ bool Timeout(time_t current);
virtual int Write(std::string data);
virtual int OnIncomingConnection(int newfd, char* ip);
void SetState(InspSocketState s);
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 7f0ea8fd8..00c7c5f79 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -2700,7 +2700,7 @@ int InspIRCd(char** argv, int argc)
InspSocket* s = (InspSocket*)*a;
if ((s) && (s->GetFd() == activefds[activefd]))
{
- if (!s->Poll())
+ if ((s->Timeout(TIME)) || (!s->Poll()))
{
log(DEBUG,"Socket poll returned false, close and bail");
SE->DelFd(s->GetFd());
diff --git a/src/socket.cpp b/src/socket.cpp
index 4e8c88663..625c0ff70 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -194,9 +194,9 @@ int InspSocket::Write(std::string data)
return written;
}
-bool InspSocket::Poll()
+bool InspSocket::Timeout(time_t current)
{
- if ((time(NULL) > timeout_end) && (this->state == I_CONNECTING))
+ if ((this->state == I_CONNECTING) && (current > timeout_end))
{
// for non-listening sockets, the timeout can occur
// which causes termination of the connection after
@@ -204,11 +204,15 @@ bool InspSocket::Poll()
// connection.
this->OnTimeout();
this->OnError(I_ERR_TIMEOUT);
- timeout = true;
+ timeout = true;
this->state = I_ERROR;
- return false;
+ return true;
}
+ return false;
+}
+bool InspSocket::Poll()
+{
int incoming = -1;
switch (this->state)