summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--louloulibs/network/dns_socket_handler.cpp3
-rw-r--r--louloulibs/network/poller.cpp5
-rw-r--r--louloulibs/network/poller.hpp4
3 files changed, 11 insertions, 1 deletions
diff --git a/louloulibs/network/dns_socket_handler.cpp b/louloulibs/network/dns_socket_handler.cpp
index 5fd08cb..403a5be 100644
--- a/louloulibs/network/dns_socket_handler.cpp
+++ b/louloulibs/network/dns_socket_handler.cpp
@@ -42,7 +42,8 @@ bool DNSSocketHandler::is_connected() const
void DNSSocketHandler::remove_from_poller()
{
- this->poller->remove_socket_handler(this->socket);
+ if (this->poller->is_managing_socket(this->socket))
+ this->poller->remove_socket_handler(this->socket);
}
#endif /* CARES_FOUND */
diff --git a/louloulibs/network/poller.cpp b/louloulibs/network/poller.cpp
index 8a6fd97..d341bb5 100644
--- a/louloulibs/network/poller.cpp
+++ b/louloulibs/network/poller.cpp
@@ -226,3 +226,8 @@ size_t Poller::size() const
{
return this->socket_handlers.size();
}
+
+bool Poller::is_managing_socket(const socket_t socket) const
+{
+ return (this->socket_handlers.find(socket) != this->socket_handlers.end());
+}
diff --git a/louloulibs/network/poller.hpp b/louloulibs/network/poller.hpp
index fc1a1a1..e39e438 100644
--- a/louloulibs/network/poller.hpp
+++ b/louloulibs/network/poller.hpp
@@ -74,6 +74,10 @@ public:
* Returns the number of SocketHandlers managed by the poller.
*/
size_t size() const;
+ /**
+ * Whether the given socket is managed by the poller
+ */
+ bool is_managing_socket(const socket_t socket) const;
private:
/**