diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:14:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:14:49 +0000 |
commit | 2f230033794fafdf10822568e763d4db68cf6c6b (patch) | |
tree | 39ca5c2325b7b43c9a28ca6d4ad4026a61e7eb97 /dnsdist-lua-network.hh | |
parent | Adding debian version 1.8.3-3. (diff) | |
download | dnsdist-2f230033794fafdf10822568e763d4db68cf6c6b.tar.xz dnsdist-2f230033794fafdf10822568e763d4db68cf6c6b.zip |
Merging upstream version 1.9.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dnsdist-lua-network.hh | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/dnsdist-lua-network.hh b/dnsdist-lua-network.hh index a63efd4..3cd2f08 100644 --- a/dnsdist-lua-network.hh +++ b/dnsdist-lua-network.hh @@ -34,16 +34,32 @@ class NetworkListener { public: NetworkListener(); + NetworkListener(const NetworkListener&) = delete; + NetworkListener(NetworkListener&&) = delete; + NetworkListener& operator=(const NetworkListener&) = delete; + NetworkListener& operator=(NetworkListener&&) = delete; + ~NetworkListener(); using EndpointID = uint16_t; using NetworkDatagramCB = std::function<void(EndpointID endpoint, std::string&& dgram, const std::string& from)>; - bool addUnixListeningEndpoint(const std::string& path, EndpointID id, NetworkDatagramCB cb); + bool addUnixListeningEndpoint(const std::string& path, EndpointID endpointID, NetworkDatagramCB callback); void start(); - void runOnce(struct timeval& now, uint32_t timeout); + void runOnce(timeval& now, uint32_t timeout); private: + struct ListenerData + { + ListenerData(); + + std::unique_ptr<FDMultiplexer> d_mplexer; + std::unordered_map<std::string, Socket> d_sockets; + std::atomic<bool> d_running{false}; + std::atomic<bool> d_exiting{false}; + }; + static void readCB(int desc, FDMultiplexer::funcparam_t& param); - void mainThread(); + static void mainThread(std::shared_ptr<ListenerData>& data); + static void runOnce(ListenerData& data, timeval& now, uint32_t timeout); struct CBData { @@ -51,9 +67,7 @@ private: EndpointID d_endpoint; }; - std::unique_ptr<FDMultiplexer> d_mplexer; - std::unordered_map<std::string, Socket> d_sockets; - std::atomic<bool> d_running{false}; + std::shared_ptr<ListenerData> d_data; }; class NetworkEndpoint |