From 9e635d9b19e72eefef082dd8071d3e4c9d6cfab1 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 7 May 2020 19:24:45 +0200 Subject: Separated out TCP socket class --- plugins/fcgi/fcgi.h | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) (limited to 'plugins/fcgi/fcgi.h') 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 #include #include #include -// TODO: multithreading -class FCGI_ID -{ - std::setm_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 m_sockets; + std::unordered_map> m_sockets; public: fcgi_plugin(); -- cgit v1.2.3