From 0c8adc85f7373a85de8b3edc6cac87d5f7389bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 11 Nov 2016 02:54:48 +0100 Subject: Move all the connect() logic from TCPSocketHandler into a subclass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way, TCPSocketHandler only deal with the message sending/receiving, not the connect() or anything else. This will be used for implementing servers (because when a client is accepted, we don’t need all the connect() and dns resolution stuff). --- louloulibs/network/dns_socket_handler.hpp | 1 + 1 file changed, 1 insertion(+) (limited to 'louloulibs/network/dns_socket_handler.hpp') diff --git a/louloulibs/network/dns_socket_handler.hpp b/louloulibs/network/dns_socket_handler.hpp index 0570196..14ba177 100644 --- a/louloulibs/network/dns_socket_handler.hpp +++ b/louloulibs/network/dns_socket_handler.hpp @@ -40,6 +40,7 @@ public: * Always true, see the comment for connect() */ bool is_connected() const override final; + bool is_connecting() const override final; void remove_from_poller(); private: -- cgit v1.2.3 From 42e85d921b0c5e10889d93c24b7ebf355287ee71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 16 Nov 2016 23:07:27 +0100 Subject: Remove some useless virtual method from SocketHandler --- louloulibs/network/dns_socket_handler.hpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'louloulibs/network/dns_socket_handler.hpp') diff --git a/louloulibs/network/dns_socket_handler.hpp b/louloulibs/network/dns_socket_handler.hpp index 14ba177..e3fed0c 100644 --- a/louloulibs/network/dns_socket_handler.hpp +++ b/louloulibs/network/dns_socket_handler.hpp @@ -31,16 +31,10 @@ public: */ void on_recv() override final; void on_send() override final; - /** - * Do nothing, because we are always considered to be connected, since the - * connection is done by c-ares and not by us. - */ - void connect() override final; /** * Always true, see the comment for connect() */ bool is_connected() const override final; - bool is_connecting() const override final; void remove_from_poller(); private: -- cgit v1.2.3 From 5b56007828f20c763df3f36ceed809188880663e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 6 Jan 2017 22:58:18 +0100 Subject: Use udns instead of c-ares fix #3226 --- louloulibs/network/dns_socket_handler.hpp | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'louloulibs/network/dns_socket_handler.hpp') diff --git a/louloulibs/network/dns_socket_handler.hpp b/louloulibs/network/dns_socket_handler.hpp index e3fed0c..e12f145 100644 --- a/louloulibs/network/dns_socket_handler.hpp +++ b/louloulibs/network/dns_socket_handler.hpp @@ -1,44 +1,33 @@ #pragma once #include -#ifdef CARES_FOUND +#ifdef UDNS_FOUND #include -#include /** - * Manage a socket returned by ares_fds. We do not create, open or close the - * socket ourself: this is done by c-ares. We just call ares_process_fd() - * with the correct parameters, depending on what can be done on that socket - * (Poller reported it to be writable or readeable) + * Manage the UDP socket provided by udns, we do not create, open or close the + * socket ourself: this is done by udns. We only watch it for readability */ - -class DNSHandler; - class DNSSocketHandler: public SocketHandler { public: - explicit DNSSocketHandler(std::shared_ptr poller, DNSHandler& handler, const socket_t socket); - ~DNSSocketHandler() = default; + explicit DNSSocketHandler(std::shared_ptr poller, const socket_t socket); + ~DNSSocketHandler(); 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 - * recv()ing the data it wants on that socket. - */ void on_recv() override final; - void on_send() override final; + /** * Always true, see the comment for connect() */ bool is_connected() const override final; - void remove_from_poller(); -private: - DNSHandler& handler; + void watch(); + void unwatch(); }; -#endif // CARES_FOUND +#endif // UDNS_FOUND -- cgit v1.2.3 From f0bc6c83a8eb548d0a3edbf7c16a6922bfd24ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 8 Mar 2017 19:04:15 +0100 Subject: Pass the shared_ptr by reference, to avoid useless copies --- louloulibs/network/dns_socket_handler.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'louloulibs/network/dns_socket_handler.hpp') diff --git a/louloulibs/network/dns_socket_handler.hpp b/louloulibs/network/dns_socket_handler.hpp index e12f145..fc5f41f 100644 --- a/louloulibs/network/dns_socket_handler.hpp +++ b/louloulibs/network/dns_socket_handler.hpp @@ -12,7 +12,7 @@ class DNSSocketHandler: public SocketHandler { public: - explicit DNSSocketHandler(std::shared_ptr poller, const socket_t socket); + explicit DNSSocketHandler(std::shared_ptr& poller, const socket_t socket); ~DNSSocketHandler(); DNSSocketHandler(const DNSSocketHandler&) = delete; DNSSocketHandler(DNSSocketHandler&&) = delete; -- cgit v1.2.3 From 0ab40dc1ab4e689921da54080b135e1d22b1c586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 14 Mar 2017 21:45:23 +0100 Subject: Refactoring louloulibs and cmake Use OBJECT libraries Remove the louloulibs directory Write FOUND variables in the cache --- louloulibs/network/dns_socket_handler.hpp | 33 ------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 louloulibs/network/dns_socket_handler.hpp (limited to 'louloulibs/network/dns_socket_handler.hpp') diff --git a/louloulibs/network/dns_socket_handler.hpp b/louloulibs/network/dns_socket_handler.hpp deleted file mode 100644 index fc5f41f..0000000 --- a/louloulibs/network/dns_socket_handler.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#ifdef UDNS_FOUND - -#include - -/** - * Manage the UDP socket provided by udns, we do not create, open or close the - * socket ourself: this is done by udns. We only watch it for readability - */ -class DNSSocketHandler: public SocketHandler -{ -public: - explicit DNSSocketHandler(std::shared_ptr& poller, const socket_t socket); - ~DNSSocketHandler(); - DNSSocketHandler(const DNSSocketHandler&) = delete; - DNSSocketHandler(DNSSocketHandler&&) = delete; - DNSSocketHandler& operator=(const DNSSocketHandler&) = delete; - DNSSocketHandler& operator=(DNSSocketHandler&&) = delete; - - void on_recv() override final; - - /** - * Always true, see the comment for connect() - */ - bool is_connected() const override final; - - void watch(); - void unwatch(); -}; - -#endif // UDNS_FOUND -- cgit v1.2.3