diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-05-07 19:24:45 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-05-07 19:24:45 +0200 |
commit | 9e635d9b19e72eefef082dd8071d3e4c9d6cfab1 (patch) | |
tree | 4e205947bc1f6b62f743faf3312f3e1e7e77f647 /plugins/fcgi/fcgi.h | |
parent | 1cc484b25547e349177cf652f62021b802f48655 (diff) |
Separated out TCP socket class
Diffstat (limited to 'plugins/fcgi/fcgi.h')
-rw-r--r-- | plugins/fcgi/fcgi.h | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/plugins/fcgi/fcgi.h b/plugins/fcgi/fcgi.h index 4f77719..289c4d6 100644 --- a/plugins/fcgi/fcgi.h +++ b/plugins/fcgi/fcgi.h @@ -2,38 +2,14 @@ #include "../../plugin_interface.h" +#include "socket.h" + #include <boost/asio.hpp> #include <cstdint> #include <mutex> #include <set> -// TODO: multithreading -class FCGI_ID -{ - std::set<uint16_t >m_unused; - uint16_t m_current_max{}; - -public: - FCGI_ID(){} - - // starting at 1 - uint16_t getID(){ - if (m_unused.empty()) { - m_current_max++; - return m_current_max; - } else { - uint16_t result{*m_unused.begin()}; - m_unused.erase(m_unused.begin()); - return result; - } - } - - void putID(uint16_t id){ - m_unused.insert(id); - } -}; - // automatically reserves ID, and releases it via RAII class FCGI_ID_Guard { @@ -57,12 +33,9 @@ struct FCGIContext; class fcgi_plugin: public webserver_plugin_interface { - FCGI_ID m_fcgi_id; - boost::asio::io_context m_io_context; - boost::asio::ip::tcp::resolver m_resolver; + SocketFactory m_socket_factory; - std::mutex m_socket_mutex; // guard m_socket use in different threads - std::unordered_map<std::string, boost::asio::ip::tcp::socket> m_sockets; + std::unordered_map<std::string, std::shared_ptr<Socket>> m_sockets; public: fcgi_plugin(); |