diff options
-rw-r--r-- | include/socketengine.h | 4 | ||||
-rw-r--r-- | src/socket.cpp | 6 | ||||
-rw-r--r-- | src/socketengine.cpp | 7 |
3 files changed, 16 insertions, 1 deletions
diff --git a/include/socketengine.h b/include/socketengine.h index d7a0f1c59..f2679811e 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -131,13 +131,15 @@ public: */ int GetRemainingFds(); - /** Delete a file descriptor f rom the engine + /** Delete a file descriptor from the engine * This function call deletes a file descriptor * from the engine, returning true if it succeeded * and false if it failed. */ bool DelFd(int fd); + bool HasFd(int fd); + /** Waits for an event. * Please note that this doesnt wait long, only * a couple of milliseconds. It returns a list diff --git a/src/socket.cpp b/src/socket.cpp index 508d638cf..23d760002 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -287,6 +287,9 @@ bool InspSocket::FlushWriteBuffer() bool InspSocket::Timeout(time_t current) { + if (!socket_ref[this->fd] || !ServerInstance->SE->HasFd(this->fd)) + return false; + if (((this->state == I_RESOLVING) || (this->state == I_CONNECTING)) && (current > timeout_end)) { log(DEBUG,"Timed out, current=%lu timeout_end=%lu"); @@ -305,6 +308,9 @@ bool InspSocket::Timeout(time_t current) bool InspSocket::Poll() { + if (!socket_ref[this->fd] || !ServerInstance->SE->HasFd(this->fd)) + return true; + int incoming = -1; bool n = true; diff --git a/src/socketengine.cpp b/src/socketengine.cpp index 3df9c2135..bcc8e23af 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -112,6 +112,13 @@ bool SocketEngine::AddFd(int fd, bool readable, char type) return true; } +bool SocketEngine::HasFd(int fd) +{ + if ((fd < 0) || (fd > MAX_DESCRIPTORS)) + return false; + return (ref[fd] != 0); +} + bool SocketEngine::DelFd(int fd) { log(DEBUG,"SocketEngine::DelFd(%d)",fd); |