From de0eff6e944db11ae3552e0cd2c191997eebaa2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 27 Jul 2016 10:04:15 +0200 Subject: =?UTF-8?q?Revert=20"Don=E2=80=99t=20use=20unique=5Fptr=20to=20sto?= =?UTF-8?q?re=20dns=20socket=20handlers"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 5328d0806fdc5becb9344b4d4320787a2b7c0712. --- louloulibs/network/dns_handler.cpp | 14 +++++++------- louloulibs/network/dns_handler.hpp | 2 +- louloulibs/network/dns_socket_handler.hpp | 4 ++-- louloulibs/network/socket_handler.hpp | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/louloulibs/network/dns_handler.cpp b/louloulibs/network/dns_handler.cpp index 24c4bcf..5e19f8c 100644 --- a/louloulibs/network/dns_handler.cpp +++ b/louloulibs/network/dns_handler.cpp @@ -68,7 +68,7 @@ void DNSHandler::watch_dns_sockets(std::shared_ptr& poller) std::remove_if(this->socket_handlers.begin(), this->socket_handlers.end(), [&readers](const auto& dns_socket) { - return !FD_ISSET(dns_socket.get_socket(), &readers); + return !FD_ISSET(dns_socket->get_socket(), &readers); }), this->socket_handlers.end()); @@ -81,8 +81,8 @@ void DNSHandler::watch_dns_sockets(std::shared_ptr& poller) this->socket_handlers.end(), [i](const auto& socket_handler) { - return i == socket_handler.get_socket(); - }); + return i == socket_handler->get_socket(); + }); if (!read && !write) // No need to read or write to it { // If found, erase it and stop watching it because it is not // needed anymore @@ -95,12 +95,12 @@ void DNSHandler::watch_dns_sockets(std::shared_ptr& poller) if (it == this->socket_handlers.end()) { this->socket_handlers.emplace(this->socket_handlers.begin(), - poller, i); + std::make_unique(poller, i)); it = this->socket_handlers.begin(); } - poller->add_socket_handler(&*it); + poller->add_socket_handler(it->get()); if (write) - poller->watch_send_events(&*it); + poller->watch_send_events(it->get()); } } // Cancel previous timer, if any. @@ -116,7 +116,7 @@ void DNSHandler::watch_dns_sockets(std::shared_ptr& poller) [this]() { for (auto& dns_socket_handler: this->socket_handlers) - dns_socket_handler.on_recv(); + dns_socket_handler->on_recv(); }, "DNS timeout")); } diff --git a/louloulibs/network/dns_handler.hpp b/louloulibs/network/dns_handler.hpp index d8b55c8..e0feb11 100644 --- a/louloulibs/network/dns_handler.hpp +++ b/louloulibs/network/dns_handler.hpp @@ -50,7 +50,7 @@ private: * call to ares_fds. DNSSocketHandlers are added to it or removed from it * in the watch_dns_sockets() method */ - std::vector socket_handlers; + std::vector> socket_handlers; ares_channel channel; }; diff --git a/louloulibs/network/dns_socket_handler.hpp b/louloulibs/network/dns_socket_handler.hpp index bd431e1..dba2f26 100644 --- a/louloulibs/network/dns_socket_handler.hpp +++ b/louloulibs/network/dns_socket_handler.hpp @@ -18,10 +18,10 @@ class DNSSocketHandler: public SocketHandler public: explicit DNSSocketHandler(std::shared_ptr poller, const socket_t socket); ~DNSSocketHandler() = default; - DNSSocketHandler(DNSSocketHandler&&) = default; - DNSSocketHandler& operator=(DNSSocketHandler&&) = default; DNSSocketHandler(const DNSSocketHandler&) = delete; + DNSSocketHandler(DNSSocketHandler&&) = delete; DNSSocketHandler& operator=(const DNSSocketHandler&) = delete; + DNSSocketHandler& operator=(DNSSocketHandler&&) = delete; /** * Just call dns_process_fd, c-ares will do its work of send()ing or diff --git a/louloulibs/network/socket_handler.hpp b/louloulibs/network/socket_handler.hpp index 869ac3b..eeb41fe 100644 --- a/louloulibs/network/socket_handler.hpp +++ b/louloulibs/network/socket_handler.hpp @@ -15,10 +15,10 @@ public: socket(socket) {} virtual ~SocketHandler() {} - SocketHandler& operator=(SocketHandler&&) = default; - SocketHandler(SocketHandler&&) = default; - SocketHandler& operator=(const SocketHandler&) = delete; SocketHandler(const SocketHandler&) = delete; + SocketHandler(SocketHandler&&) = delete; + SocketHandler& operator=(const SocketHandler&) = delete; + SocketHandler& operator=(SocketHandler&&) = delete; virtual void on_recv() = 0; virtual void on_send() = 0; -- cgit v1.2.3